Help: DataRelation object

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear all,

I have a dataset which contains 2 DataTable
The idea is to bind a text box control with one table field and then
diaplaye the associated content of the second table based on the first table
entry.

For that I have been guide to use data relation bettween those two table.
The following code illustrate what I have done :

----->

ds.Tables.AddRange(New DataTable() {tblCustomer, tblApplication})

' Create a DataRelation, and add it to the DataSet.
Dim dr As DataRelation
dr = New DataRelation("custToApp",
tblCustomer.Columns.Item("ORDER"), tblApplication.Columns.Item("ORDER_ID"))
ds.Relations.Add(dr)

Me.ListBox1.DataSource = ds.Tables("CUSTOMER")
Me.TextBox1.DataBindings.Add(New Binding("Text", tblCustomer, "NAME"))

DataGrid1.Visible = True
DataGrid1.DataSource = ds.Tables(1)

---->

As a result I was expected that for the first entry of customer table, the
correponding appication records for that customer gets displayed in the
datagrid, becasue of this relation ojbect.

But insatead in the datagrid I get all records of my application table and
not only the one from one customer name.

What I am doing wrong or did not understand complety. As far as I understand
realtion between 2 coluumns from 2 different table should displayed only
related information..

Thnaks fro your help
serge
 
HOw to bind the relation to the datagrid ?

The relation is bind to the dataset, which is linked to the datasource of
the datagrid
Does it not the same?

thansk for your info
 
Serge,


Serge

Probably however I am always figthing with this one.

DataGrid1.SetDataBinding(ds, "tblCustomers.custToApp")

I hope this helps,

Cor
 
Back
Top