DataSet Relations

  • Thread starter Thread starter Matt Frame
  • Start date Start date
M

Matt Frame

I need to know if there is a way to say take ds1 and ds2 and put them into
the same dataset where I can create a relationship and have a parent child
relationship. I know this can be done by using the SqlDataAdapter and using
the same dataset with the Fill method, but can it be done without doing
this?

Thanks,

Matt
 
Matt,

Haven't tried it, but I guess the following should work :

dim NewDataSet as New Dataset
NewDataSet.Tables.Add ( OldDataSet.Tables( <NameTable1>))
NewDataSet.Tables.Add ( OldDataSet.Tables( <NameTable2>))
...... Add relation to NewDataSet between Table1 and Table2

Regards,
Jan
 
Matt:
The main way this is accomplished is with two or more dataadapters, creating
multiple tables and using a datarelation object. You could write a Server
side Join which would populate one table with all of the data, but if you
want two (or more) different tables related without the evil redundancy
inherent in using the join syntax, a DataRelation is the only way I konw to
do it. I guess you could use a DataReader (two or more) and construct a
datatable from it, and use those datatalbes with a DataRelation to
accomplish this, but that would probably be way more work than it's worth.

You can also use Typed DataSets but the ultimate logic is essentially the
same and if I understand the objective correctly, you want to get away from
using a DataAdatper. If that assumption is correct, the only way I know of
would be to use datareaders and build the tables...

HTH,

Bill
 
Back
Top