G
Guest
I had my form working fine with a stronly Typed dataset - now that I have convered it to Untyped - I am getting a duplicate row, only in my child table.
I have the dataadapters configured to NOT refresh the dataset on insert of update. For each table I add to the dataset, I use da.MissingSchemaAction = MissingSchemaAction.AddWithKey.
This is my code to set the relation. I changed the table names to "Parent" and "Child" below for clarity. Parent table is keyed on ConfRegID (Not Autoincrement), child table keyed on AttendeeID (IS Autoincrement).
Dim dcParent As DataColumn = ds.Tables("Parent").Columns("ConfRegID")
Dim dcChild As DataColumn = ds.Tables("Child").Columns("ConfRegID")
Dim fkCon As ForeignKeyConstraint = New ForeignKeyConstraint("RegAttFK", dcParent, dcChild)
fkCon.UpdateRule = Rule.Cascade
fkCon.DeleteRule = Rule.Cascade
fkCon.AcceptRejectRule = Rule.Cascade
ds.Tables("Child").Constraints.Add(fkCon)
Dim relRegAttend As New DataRelation("ConfRegConfAttendee", dcParent, dcChild, True)
ds.Relations.Add(relRegAttend)
I've tried it with and without the middle block - defining the ForeignKeyConstraint (does anyone know why I can't add that after the datarelation? I get an error).
This is my code to save:
daConfRegistation.Update(dsChanges.Tables("Parent").Select("", "", DataViewRowState.Added Or DataViewRowState.ModifiedCurrent))
Me.daConfAttendee.Update(dsChanges.Tables("Child"))
daConfRegistation.Update(dsChanges.Tables("Parent"))
ds.Merge(dsChanges)
ds.AcceptChanges() 'I tried it with and without this line.
Can someone please help - I'm so frustrated by this. I've tried everything I can think of.
Thanks,
Denise
I have the dataadapters configured to NOT refresh the dataset on insert of update. For each table I add to the dataset, I use da.MissingSchemaAction = MissingSchemaAction.AddWithKey.
This is my code to set the relation. I changed the table names to "Parent" and "Child" below for clarity. Parent table is keyed on ConfRegID (Not Autoincrement), child table keyed on AttendeeID (IS Autoincrement).
Dim dcParent As DataColumn = ds.Tables("Parent").Columns("ConfRegID")
Dim dcChild As DataColumn = ds.Tables("Child").Columns("ConfRegID")
Dim fkCon As ForeignKeyConstraint = New ForeignKeyConstraint("RegAttFK", dcParent, dcChild)
fkCon.UpdateRule = Rule.Cascade
fkCon.DeleteRule = Rule.Cascade
fkCon.AcceptRejectRule = Rule.Cascade
ds.Tables("Child").Constraints.Add(fkCon)
Dim relRegAttend As New DataRelation("ConfRegConfAttendee", dcParent, dcChild, True)
ds.Relations.Add(relRegAttend)
I've tried it with and without the middle block - defining the ForeignKeyConstraint (does anyone know why I can't add that after the datarelation? I get an error).
This is my code to save:
daConfRegistation.Update(dsChanges.Tables("Parent").Select("", "", DataViewRowState.Added Or DataViewRowState.ModifiedCurrent))
Me.daConfAttendee.Update(dsChanges.Tables("Child"))
daConfRegistation.Update(dsChanges.Tables("Parent"))
ds.Merge(dsChanges)
ds.AcceptChanges() 'I tried it with and without this line.
Can someone please help - I'm so frustrated by this. I've tried everything I can think of.
Thanks,
Denise