What's the most efficent way to create a dataset table from a join

G

Guest

Hi, I'm using vs2005 and .net 2.0
I used 2 DirectorySearchers to retrieve data from Active Directory and
placed them in 2 dataset tables. I need to perform the SQL equuvakebt of
join operation to create a 3rd dataset table that I will then pass to Crystal
Report.
1. Sometimes there could be 100,000 records or more per table. Is this the
most time efficient way to do it?
2. I tried using the datarelation and looping through each datarow but I'm
getting run time error something like" there is no matching value for each
parent value....". I want to retrieve the "join" records so there would be
times that a record is in one table but not the other but it's giving me
error so what should I do now to retrived the join records?
3. I didn't define primary key for either tables. Do I need to do that
first to address the error?
4. My datarelation code:
dsReport.Relations.Add("relationComputers",
dsReport.Tables["PadComputers"].Columns["cn"],
dsReport.Tables["AdComputers"].Columns["objectSid"]);
 
C

ClayB

If the child table has rows not related to the parent table, then I do
not think you will be able to use DataRelations to manage this task.

You could brute force it by sorting both DataTables on the 'matched'
columns. Then you could iterate through the Rows collections of
DataTables in a common loop adding the new rows to your 3rd DataTable.
Since the original 2 tables are sorted, it would be straight-forward to
know when there are matching rows in the original DataTables to allow
you to add a new joined row to the 3rd DataTable in this case and also
to recognize when you have to add a row based only on one of the
original DataTables.

================
Clay Burch
Syncfusion, Inc.
 
G

Guest

Do I have to create a dataview for each of the datatable to do a sort on each
of the table? I don't think datatable has sort method. Or should I do
Select statement with sort?
 

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