By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,761 Members | 1,193 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,761 IT Pros & Developers. It's quick & easy.

Create DataSet relation with more than 1 field

P: n/a
I have two tables that are linked by 2 fields (ID1 and ID2). Is it possible
to create this relation once the tables are in a DataSet? I can create a
relation using a single field, but I don't know if this is possible with
multiple fields.

Thanks,

Jan 9 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a

Tim Kelley wrote:
I have two tables that are linked by 2 fields (ID1 and ID2). Is it possible
to create this relation once the tables are in a DataSet? I can create a
relation using a single field, but I don't know if this is possible with
multiple fields.

Thanks,
Hi,
This is how you can do .... I have given code snippet. I think
this will be useful for your problem.

DataSet ds;
DataTable dt1;
DataTable dt2;
ds.Tables.Add(dt1);
ds.Tables.Add(dt2);
DataRelation dr1 = new DataRelation("ID1 RELATION",
"PARENTID1", "CHILDID1");
dr1.ParentTable = dt1;
dr1.ChildTable = dt2;
DataRelation dr2 = new DataRelation("ID2 RELATION",
"PARENTID2", "CHILDID2");
dr2.ParentTable = dt1;
dr2.ChildTable = dt2;
ds.Relations.Add(dr2);

Jan 10 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.