I have a parent / child relationship defined using the data designer in vb. I've specified that on DELETE, it should set the child records to null.
The delete itself it working just fine. But since adding this relationship, my code to refresh the two datagrids that hold the parent and child records is failing.
The error message is:
Message="Cannot clear table Territory because ForeignKeyConstraint FK_Contacts_Territory enforces constraints and there are child rows in Contacts"
The code behind my Refresh button looks like:
If Me.ContactsTableAdapter.ClearBeforeFill And Me.TerritoryTableAdapter.ClearBeforeFill Then
Me.TerritoryTableAdapter.FillBySortedName(TerritoryDS.Territory)
Me.ContactsTableAdapter.Fill(TerritoryDS.Contacts)
End If
Any suggestions?
The delete itself it working just fine. But since adding this relationship, my code to refresh the two datagrids that hold the parent and child records is failing.
The error message is:
Message="Cannot clear table Territory because ForeignKeyConstraint FK_Contacts_Territory enforces constraints and there are child rows in Contacts"
The code behind my Refresh button looks like:
If Me.ContactsTableAdapter.ClearBeforeFill And Me.TerritoryTableAdapter.ClearBeforeFill Then
Me.TerritoryTableAdapter.FillBySortedName(TerritoryDS.Territory)
Me.ContactsTableAdapter.Fill(TerritoryDS.Contacts)
End If
Any suggestions?