R
russzee
Hello,
I'm working with NorthWind
My Customers Form uses Untyped Dataset and Bound Controls
(BindingManagerBase). However, deleting a customer and updating the
database is
throwing an error because of Referential Integrity issues.
I'm trying to use DataRelations to resolve this issue.
- I've filled my Dataset with Customers, Orders and Order Details Table
- I then created two DataRelations as below :
' Creating the DataRelation between Customers and Orders Tables
Dim CustomersOrders As New DataRelation("CustomersOrders", _
dsCustomers.Tables("Customers").Columns("CustomerID"), _
dsCustomers.Tables("Orders").Columns("CustomerID"))
dsCustomers.Relations.Add(CustomersOrders)
' Creating the DataRelation between Orders and Order Details Tables
Dim OrderRelation As New DataRelation("OrderRelation", _
dsCustomers.Tables("Orders").Columns("OrderID"), _
dsCustomers.Tables("Order Details").Columns("OrderID"))
dsCustomers.Relations.Add(OrderRelation)
Here's my question :
How do I update my database so that when a Customer is deleted , the
corresponding Information in the Orders and Order Details Tables are
first deleted in the dataset and then on clicking the "Update Database"
button the changes in all 3 tables are reflected to the database.
Currently, I'm using the sqlcommandbuilder object seperately for each
dataadapter and using its Fill Method seprately to Update the database.
I know I'm missing something since this doesnt seem to work.
Thank You,
russzee
I'm working with NorthWind
My Customers Form uses Untyped Dataset and Bound Controls
(BindingManagerBase). However, deleting a customer and updating the
database is
throwing an error because of Referential Integrity issues.
I'm trying to use DataRelations to resolve this issue.
- I've filled my Dataset with Customers, Orders and Order Details Table
- I then created two DataRelations as below :
' Creating the DataRelation between Customers and Orders Tables
Dim CustomersOrders As New DataRelation("CustomersOrders", _
dsCustomers.Tables("Customers").Columns("CustomerID"), _
dsCustomers.Tables("Orders").Columns("CustomerID"))
dsCustomers.Relations.Add(CustomersOrders)
' Creating the DataRelation between Orders and Order Details Tables
Dim OrderRelation As New DataRelation("OrderRelation", _
dsCustomers.Tables("Orders").Columns("OrderID"), _
dsCustomers.Tables("Order Details").Columns("OrderID"))
dsCustomers.Relations.Add(OrderRelation)
Here's my question :
How do I update my database so that when a Customer is deleted , the
corresponding Information in the Orders and Order Details Tables are
first deleted in the dataset and then on clicking the "Update Database"
button the changes in all 3 tables are reflected to the database.
Currently, I'm using the sqlcommandbuilder object seperately for each
dataadapter and using its Fill Method seprately to Update the database.
I know I'm missing something since this doesnt seem to work.
Thank You,
russzee