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

DataRelation and Fill(ds, int, int, dt)

P: n/a
I've filled a DataSet with two tables then established a DataRelation; all
is well because the backend includes RI rules that ensure that no record on
the detail side will be without a master record. However, there are too
many records on the master side for an efficient use of the app over the web
via website or VPN. So, I've implemented Fill(ds, int, int, dt) such that I
control how many records are downloaded. Now the problem is that the detail
table is left with many records that have no corresponding records on the
master side and the DataRelation won't take.

My question is what is the best method of fetching only the related records?
I've seen GetChildRows, but I'm hoping that there is a 'built-in' way of
doing this through the DataAdapter. If not, then my question is do I use
this or something like it:

DataRow[] arrRows;
foreach(DataRow masterRow in masterTable.Rows){
arrRows = masterRow.GetChildRows(myRelation);
....
}

If so, how do I get arrRows into the correct Table of the DataSet? Is
foreach with the Add method of the DataRowCollection class the way to go
with this?

Thanks.
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Christopher,

I would collect all master table primary key values, create a sql select
statement for detail rows with something like WHERE master.primarykey IN (my
values) and fill only these detail rows.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
SLODUG - Slovene Developer Users Group www.codezone-si.info

"Christopher Weaver" <we*****@verizon.net> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I've filled a DataSet with two tables then established a DataRelation; all
is well because the backend includes RI rules that ensure that no record
on the detail side will be without a master record. However, there are
too many records on the master side for an efficient use of the app over
the web via website or VPN. So, I've implemented Fill(ds, int, int, dt)
such that I control how many records are downloaded. Now the problem is
that the detail table is left with many records that have no corresponding
records on the master side and the DataRelation won't take.

My question is what is the best method of fetching only the related
records? I've seen GetChildRows, but I'm hoping that there is a 'built-in'
way of doing this through the DataAdapter. If not, then my question is do
I use this or something like it:

DataRow[] arrRows;
foreach(DataRow masterRow in masterTable.Rows){
arrRows = masterRow.GetChildRows(myRelation);
....
}

If so, how do I get arrRows into the correct Table of the DataSet? Is
foreach with the Add method of the DataRowCollection class the way to go
with this?

Thanks.

Nov 17 '05 #2

P: n/a
This is good. Thanks.

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:eK**************@TK2MSFTNGP10.phx.gbl...
Hi Christopher,

I would collect all master table primary key values, create a sql select
statement for detail rows with something like WHERE master.primarykey IN
(my values) and fill only these detail rows.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
SLODUG - Slovene Developer Users Group www.codezone-si.info

"Christopher Weaver" <we*****@verizon.net> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I've filled a DataSet with two tables then established a DataRelation;
all is well because the backend includes RI rules that ensure that no
record on the detail side will be without a master record. However,
there are too many records on the master side for an efficient use of the
app over the web via website or VPN. So, I've implemented Fill(ds, int,
int, dt) such that I control how many records are downloaded. Now the
problem is that the detail table is left with many records that have no
corresponding records on the master side and the DataRelation won't take.

My question is what is the best method of fetching only the related
records? I've seen GetChildRows, but I'm hoping that there is a
'built-in' way of doing this through the DataAdapter. If not, then my
question is do I use this or something like it:

DataRow[] arrRows;
foreach(DataRow masterRow in masterTable.Rows){
arrRows = masterRow.GetChildRows(myRelation);
....
}

If so, how do I get arrRows into the correct Table of the DataSet? Is
foreach with the Add method of the DataRowCollection class the way to go
with this?

Thanks.


Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.