multiple relation in dataset

G

Guest

Hi there,

I have a dataset with two tables. They both have two columns which are
related (sort of a joined key). I know how to create one relation:

ds.Relations.Add("myrelation",
ds.Tables["authors"].Columns["au_id"],
ds.Tables["titles"].Columns["au_id"]);


How can I create a relation to the column "issue_number" in the same
relation? Or how do I approach this?

Thank you

Chris
 
D

Dale Preston

Depending on what you are trying to do, you can either create two separate
relations or you can use one of the DataRelation constructors that take
DataColumn arrays as parameters like this:

ds.Relations.Add("myrelation", new DataColumn[] {

ds.Tables["Authors"].Columns["au_id"],

ds.Tables["Authors"].Columns["issue_number"] },

new DataColumn[] {

ds.Tables["Titles"].Columns["au_id"],

ds.Tables["Titles"].Columns["issue_number"] });

HTH

Dale Preston
MCAD, MCDBA, MCSE
 

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

Top