Visual Basic: Only save inserted records in a DataTable back to a database.

Platform:Visual Basic
Task:Only save inserted records in a DataTable back to a database.
Discussion:
I ran into a situation where my TableAdapterManager was trying to save inserts to a child table before the parent table. This will obviously cause problems with referential integrity. I needed a way to force a save on the parent table's inserted records before the TableAdapterManager mangled the processing order of the child table's inserted records. I inserted the following before calling the TableAdapterManager's UpdateAll method.
Example:
Dim InsertedRecordsDataTable As DataTable = AKRODataSet.tblVitalSigns.GetChanges(DataRowState.Added)
Me.TblVitalSignsTableAdapter.Update(InsertedRecordsDataTable) 'tableadaptermanager is trying to process vsparks before vs, force inserts to vs here
Me.TableAdapterManager.UpdateAll(Me.AKRODataSet)
Back to Index