ADO.NET - BindingContext and Disappearing Rows
-
I am using a
DataSet
which contains twoDataTables
. The 2 Tables are related using aDataRelation
and it's a One-to-One Relationship. On a Form, I create a DataView for the Top-Level Parent Table and access the Child table through the DataMember when using the BindingContext. One my Form, I am usingMe.BindingContext(dvData).AddNew()
for the Parent Table. I then useMe.BindingContext(dvData, "ChildRelationship").AddNew()
to Add a new Record at the Child Level. I do this because the Form edits data in both Tables at the same time so that to the User, they will not have to make 2 edits just to get data in both tables. When I debug after doing this, everything is great! I can see both new Rows added to the DataView and the Form works as expected since it is data bound. However, in mySave
Routine, I modify a few Columns if the Data wasn't supplied, and lastly call theMe.BindingContext(dvData).EndCurrentEdit()
andMe.BindingContext(dvData, "ChildRelationship").EndCurrentEdit()
. When I do this, and attempt to save the Data back to the Database, it has the Parent Row, but the Child Table's Row (that was previously there) is no longer there! Filtering the DataTable on only Modified / New Rows results in no data, and also the Row Count is the same as before any Rows were added. It's as if the New Row on the Child Table just disappeared!!! :wtf: Does anyone have any insight?? :confused: