Adding to a database through a form... RRS feed

  • Question

  • Hi ive got a form, and what im trying to do is to take data that has been imputed into txtboxes and then save that data onto a database.  The code is as below...



    Public Class Addmember

    Private deptconnection As New OleDb.OleDbConnection()

    Private dataadapter As OleDb.OleDbDataAdapter

    Private commandbuilder As OleDb.OleDbCommandBuilder

    Private Members As New DataTable

    Private ds As New DataSet

    Private rowposition As Integer = 0

    Private intchange As Integer

    Private memberconnection As New OleDb.OleDbConnection()

    Dim conn As New DataSet




    Private Sub btnbackmember_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnturnback.Click



    End Sub

    Private Sub btnaddmember_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaddmember.Click


    'If txtforename.Text <> "" And txtsurname.Text <> "" And txtage.Text <> "" And txtdob.Text <> "" And txtaddress1.Text <> "" And txtaddress2.Text <> "" And txttown.Text <> "" And txtpostcode.Text <> "" And txttel.Text <> "" And txtemergencyname.Text <> "" And txtemergencytel.Text <> "" Then

    'rowposition = Members.Rows.Count - 1

    'Dim drnewrow As DataRow = Members.NewRow

    'drnewrow("M_Forename") = txtforename.Text

    'drnewrow(0) = txtforename.Text

    'drnewrow("M_Surname") = txtsurname.Text

    'drnewrow("M_Age") = txtage.Text

    'drnewrow("M_DOB") = txtdob.Text

    'drnewrow("M_AddressLine1") = txtaddress1.Text

    'drnewrow("M_AddressLine2") = txtaddress2.Text

    'drnewrow("M_Town") = txttown.Text

    'drnewrow("M_Postcode") = txtpostcode.Text

    'drnewrow("M_TelNo") = txttel.Text

    'drnewrow("M_EmergencyContactName") = txtemergencyname.Text

    'drnewrow("M_EmergencyConatctTelNo") = txtemergencytel.Text



    'rowposition = Members.Rows.Count - 1

    'End If



    End Sub

    Private Sub Addmember_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    deptconnection.ConnectionString = "provider = Microsoft.jet.oledb.4.0;" & " data source = Scout Network (IVA).mdb"


    dataadapter = New OleDb.OleDbDataAdapter("select * from Members", deptconnection)

    commandbuilder = New OleDb.OleDbCommandBuilder(dataadapter)


    'dataadapter.fill(ds, "members")



    End Sub

    End Class



    Help would be much apprichated because im pritty new to programing
    Tuesday, February 26, 2008 11:46 AM

All replies

  • Can you provide us more information on what is it that you are trying to do and what is the problem you are facing?
    Tuesday, April 7, 2009 9:39 PM