0
Hi csanchez
if u want to create a relation between Customers & Orders Tables , you can do this:
parentCol = ds.Tables["Customers"].Columns["Customer_ID"];
childCol = ds.Tables["Orders"].Columns["Customer_ID"];
// create a Relation called "CustOrder"
DataRelation dr = new DataRelation("CustOrder", parentCol, childCol)
// add a relation
ds.Relations.Add(dr);
now datarelation added in your dataset
if u want to get a specific row, you can use SelectedIndex prop
int x = listBox1.SelectedIndex;
parentRow = ds.Tables["Customers"].Rows[x];
childRow = parentRow.GetChildRows(dr);
foreach(DataRow drow in childRow)
{
Console.WriteLine(drow["Column1"]+" "+["Column2"].ToString());
}
then u will get all the related records for that particular row.
if u still have questions, then u can ask me.
bye
0
Somebody knows about DataSet.Relations.Add() and GetChildRows()?
How do they work?
thanx.
0
What is a trigger?
My questions are:
For example:
I have the next Data Base:
*Customers*
----------------
ID_Customer
Name
Address
TelephoneNum
*Orders*
-------------
ID_Order
ID_Cliente
Date
- I want to create a relationship (Customers.ID_Customer = Orders.ID_Customer). How can I create it?
- In my application the user can delete a customer, but I want to know wether or not the customer have orders, if the costumer have one or more orders I have to display a message: "Is not possible delete this Customer". How can I do it?
Thanx
Carlos
0
That's why you have relationships in a database. you can use a trigger.