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

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

P: n/a
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"]);

--
Thanks.
Jan 26 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

Jan 26 '07 #2

P: n/a
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?
--
Thanks.
"ClayB" wrote:
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.

Jan 26 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.