Ok so I am writing code to a contacts database and as i add new info to the table it is not committing to the table.

I have attached my program... idk if you will be able to open it.

But I have 2 buttons one adds a new row to a datagrid and the save is suppose to save the data in the grid to the table called contacts.mdf

Private Sub btnSave_Click(ByVal sender As System.Object,
                ByVal e As System.EventArgs) Handles btnSave.Click
        Try
            If newDataAdded Then
                Me.Validate()
                Me.ContactsBindingSource.EndEdit()
                Me.ContactsTableAdapter.Fill(Me.ContactsDataSet.Contacts)
                newDataAdded = False
            Else
                Me.Validate()
                Me.ContactsBindingSource.EndEdit()
                Me.TableAdapterManager.UpdateAll(Me.ContactsDataSet)
            End If


        Catch ex As Exception
            MessageBox.Show(ex.Message, "Data Error", MessageBoxButtons.OK,
                                       MessageBoxIcon.Error)
        End Try
    End Sub

this is what i have amounted to to try... but yet no success.

If you could help me to understand how to commit data in vb.net would be much appreciated

This is an access database. I am using sql. The code shown does not explain to me how to use the features in vb to press a button and save the data to the table. The program there is using user defined insert code wheres I want to use predefined vb functions. I am trying to understand the 2008 vb database functions. I could very easily write my way around the database management thing however that's not my goal as a beginner in this.

This article has been dead for over six months. Start a new discussion instead.