Me again,

I have some problems for updating a datasource from a datagrid.

My form has a dataset with 2 tables (tblCD_Detail and tblCD) which have a master detail relationship. There is also a datagrid (datagrid1) which displays the tblCD_detail fields corresponding with the selected tblCD.

The user can make changes in the datagrid, but the problem is how to update the corresponding datasource when the form is closed. Herefore I wrote the following code:


Private Sub test_Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If dataset.HasChanges(DataRowState.Modified) Then
Dim commandbuilder As OleDbCommandBuilder

commandbuilder = New OleDbCommandBuilder(DACD_detail)
DACD_detail.Update(dataset, "tblCD_detail")

End If
end sub


I use the commandbuilder because I wrote the dataadapter myself (I didn't use the wizard), I also used the same dataadapter as the one I used to create the datatable tblCD_detail.

When I run the form, I don't get an error but my database isn't updated. Does anybody know what I'm doing wrong???

Has it something to do with the relationship between the tables?

Thanx,

Tom