Hi all,

I have created a simple SQL Server database by Visual Studio 2005, with one table 'Friends' that has just ID, Name, Phone, Email.

Then created a datagrid to this table (just by dragging the table name from the 'Data Sources' explorer to the form.

When I run the application, the form reads the data correctly in the data grid, but when I update, add new, or delete a record, then click save, it accepts the action but no modification is done the table! I only can change the data by accessing the table from the 'Database Explorer'.

Any Idea how to solve this problem plz.

Here's the code of the data adapter of the datagrid:

Form Load:

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

        Me.FriendsTableAdapter.Fill(Me.TestDB2DataSet.Friends)

End Sub

The Save Button code:

Private Sub FriendsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FriendsBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.FriendsBindingSource.EndEdit()
        Me.FriendsTableAdapter.Update(Me.TestDB2DataSet.Friends)

End Sub

Thanks for help

this is supposed to update the database?

Me.FriendsTableAdapter.Update(Me.TestDB2DataSet.Friends)

I've never done it that way, how does it work?

This code is associated to the "Save" button of the Data Grid navigation bar. It is auto-generated by the Visual Basic 2005 when you drag the table name (in this case Friends) from the "Data Sources Explorer" to the form.

Relax, problem is solved.

Actually I don't know where the problem was or how it was solved. I just deleted the whole form and reconstructed it in the same way (!!) but it worked this time.

Lesson learned till now: If the data grid doesn't update, reconstruct the form :-/ .

I found a better solution than recreating the form. I did the following steps and it worked perfect with me:

1) Go to menu Data >> Select Data Sources

2) Right-Click the dataset that your datagrid is based on

3) Click on "Edit Dataset with designer"

4) Find your table >> right click on the TableAdapter (beneath the table's fields) which is supposed to update your data >> select "Configure..."

5) Click "Advanced Options" and make sure that all the options are checked (here's the point).

6) Good luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.