Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I'm quite familiar with how to update a single datagrid so the source database table if updated.

 


dsInsertedRows = dsDataSet.GetChanges(DataRowState.Added)
dsModifiedRows = dsDataSet.GetChanges(DataRowState.Modified)
dsDeletedRows = dsDataSet.GetChanges(DataRowState.Deleted)

If Not dsInsertedRows Is Nothing Then
 odbdaDataBase.Update(dsInsertedRows)
End If

If Not dsModifiedRows Is Nothing Then
 odbdaDataBase.Update(dsModifiedRows)
End If

If Not dsDeletedRows Is Nothing Then
 odbdaDataBase.Update(dsDeletedRows)
End If

dsDataSet.AcceptChanges()

However, I'm working on a solution that utilizes a single dataset that contains 3 different database tables (3 data adapters) that are linked by 2 data relations. The data from each table is displayed in a seperate datagrid. My problem is if I use the same type of code as above to update the complete dataset an error is generated when trying to update a data adapter that doesn't have a change.

 

If Not dsModifiedRows Is Nothing Then
 odbdaDataBaseTable1.Update(dsModifiedRows)
 odbdaDataBaseTable2.Update(dsModifiedRows)
 odbdaDataBaseTable3.Update(dsModifiedRows)
End If

I haven't bee able to figure out a way to capture the changes (GetChanges) for a particular data adapter.

 

Any suggestions? Thanks in advance.

 

[edit]added [vb ] tags [/vb ][/edit]

Edited by Robby
Posted
I have been able to make the update function properly. However, you have to select update after each change. If changes were made to multiple datagrid records and then update was selected only the first datagrid would update properly, all other changes were lost.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...