|
-
Dec 1st, 2003, 10:29 AM
#1
Thread Starter
Lively Member
how to update datasource from datagrid?
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|