Binding Manager Remove At question.

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

In my Form, there is Invoice Master to - InvoiceDetail (one-to-may
relationship)
I use bmMaster.removeat(bmMaster.position) to remove the Master record.
However, I don't know how to remove the Detail records ????
I got relationkey between that two tables.

Dim constraint_tinvno As New ForeignKeyConstraint("fk_tinvno",
dtTvHeader.Columns("tinvno"), dtTvDetail.Columns("tinvno"))
dtTvDetail.Constraints.Add(constraint_tinvno)
dsTvHeader.Relations.Add("fk_tinvno",
dtTvHeader.Columns("tinvno"), dtTvDetail.Columns("tinvno"), False)
 
Agnes said:
In my Form, there is Invoice Master to - InvoiceDetail (one-to-may
relationship)
I use bmMaster.removeat(bmMaster.position) to remove the Master record.
However, I don't know how to remove the Detail records ????
I got relationkey between that two tables.

Dim constraint_tinvno As New ForeignKeyConstraint("fk_tinvno",
dtTvHeader.Columns("tinvno"), dtTvDetail.Columns("tinvno"))
dtTvDetail.Constraints.Add(constraint_tinvno)
dsTvHeader.Relations.Add("fk_tinvno",
dtTvHeader.Columns("tinvno"), dtTvDetail.Columns("tinvno"), False)
Have a look at this article. It covers your area of interest.

http://msdn.microsoft.com/msdnmag/issues/04/05/DataPoints/
 
Agnes said:
In my Form, there is Invoice Master to - InvoiceDetail (one-to-may
relationship)
I use bmMaster.removeat(bmMaster.position) to remove the Master record.
However, I don't know how to remove the Detail records ????
I got relationkey between that two tables.

Dim constraint_tinvno As New ForeignKeyConstraint("fk_tinvno",
dtTvHeader.Columns("tinvno"), dtTvDetail.Columns("tinvno"))
dtTvDetail.Constraints.Add(constraint_tinvno)
dsTvHeader.Relations.Add("fk_tinvno",
dtTvHeader.Columns("tinvno"), dtTvDetail.Columns("tinvno"), False)
Here's an example code snippet that illustrates what you need to do:

' Creating the DataRelation between Customers and Orders Tables
Dim pCol1 As DataColumn
Dim cCol1 As DataColumn
Dim myFKC1 As ForeignKeyConstraint

pCol1 = dsCustomers.Tables("Customers"­).Columns("CustomerID")
cCol1 = dsCustomers.Tables("Orders").C­olumns("CustomerID")

Dim CustomersOrders As New DataRelation("CustomersOrders"­, pCol1,
cCol1)
dsCustomers.Relations.Add(Cust­omersOrders)
myFKC1 = New ForeignKeyConstraint("Customer­sOrders1", pCol1, cCol1)
'******************************************************************
' By setting the DeleteRule to Rule.Cascade, child table records related to
the parent table
' record you delete will be deleted automatically
myFKC1.DeleteRule = Rule.Cascade
myFKC1.UpdateRule = Rule.Cascade
dsCustomers.Tables("Orders").­Constraints.Add(myFKC1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top