multiple relation in dataset

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top