New Information adds to DataGrid But doesnt get saved to database?

Adam1991

New member
Joined
Sep 5, 2009
Messages
1
Programming Experience
1-3
Hello i wanted my user to type in the textboxes there username and password, then click of a button they will be added to the database. Ive coded it and got to the point where the information gets added to the datagrid on my form but when i close it and debug again it hasnt been added to my data base, also i have made it show all the information in the database on the datagrid on form load so there isnt a connection problem here is my code so far..

VB.NET:
Try

            datasetNewRow = datatable.NewRow
            datasetNewRow.Item("Username") = txtUsername.Text
            datasetNewRow.Item("Password") = txtPassword.Text
            datatable.Rows.Add(datasetNewRow)

            Dim dataset As New DataSet()
            dataset = New DataSet()
            dataset.Tables.Add(datatable)
            datagrid.DataSource = datatable


            MsgBox("New Record added to the Database")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Here is my Declarations if u need them..

VB.NET:
Dim datatable As New DataTable("UsersPasswords")
Dim dataset As New DataSet
Dim commandbuilder As New OleDb.OleDbCommandBuilder(adapter)
Dim datasetNewRow As DataRow

Thanks for your help, i think your going to tell me that "datagrid.DataSource = datatable" needs to be "datagrid.setdatabindings" as i have researched it.. but i cannot use it as it doesnt let me use it, its not there in my vb!!

Hope ive made sense thank you
 
Back
Top