FreeriderUK
Well-known member
I have a parent table (tbCustomers) with child table (tbJobs) in my Access DB
Everything was working well, until I decided to add a Foreign Key Constraint.
This is what basically happens when I add a new customer:
When I add a new customer and try to re-fill the dataset, I get the following error:
Which seems fair enough. But what am I doing wrong?
Everything was working well, until I decided to add a Foreign Key Constraint.
This is what basically happens when I add a new customer:
VB.NET:
Me.Validate()
Me.TbCustomersBindingSource.EndEdit()
Dim CustomersTable As DataTable = Me.MyDataSet.tbCustomers.GetChanges()
'Updates
Try
Dim CustomerUpdates() As DataRow = Me.MyDataSet.tbCustomers.Select("", "", DataViewRowState.Added Or DataViewRowState.ModifiedCurrent)
Me.TbCustomersTableAdapter.Update(CustomerUpdates)
Catch ex As Exception
MsgBox("Couldn't update customers")
End Try
Me.TbCustomersTableAdapter.FillBySelection <---- The error occurs here
When I add a new customer and try to re-fill the dataset, I get the following error:
Cannot clear table tbCustomers because ForeignKeyConstraint tbCustomers_tbJobs enforces constraints and there are child rows in tbJobs.
Which seems fair enough. But what am I doing wrong?