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

GetChildRows

P: n/a
I've writtten the following (which compiles and runs). For some reason,
TaskRows is always empty.

DataRow[] TaskRows;
foreach(DataRow TaskRow in dsTaskActivities.Tables["Tasks"].Rows)
{
TaskRows = TaskRow.GetChildRows(relTaskActivities);
foreach(DataRow dr in TaskRows)
{
dsTaskActivities.Tables["Activity"].Rows.Add(dr);
}
}

I've confirmed that the DataRelation relTaskActivities in TaskActivities
works and that there is data there for it to grab; I've used this
DataRelation to fill a grid using the DA.Fill method. I'm attempting to use
GetChildRows only because I need to use DA.Fill(DataSet, int, int, string)
on the master table because there are too many records to make the download
time practicle over the web.

If anyone can tell me why GetChildRows isn't returning any rows or any other
way to accomplish the same task, I would really appreciated it. One person
suggested using a 'WHERE ... IN' query and I'm considering it, but it seems
like GetChildRows was created for this purpose.
Nov 17 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
First of all, u are modifying the collection which u are current iterating
on. and i could not understand what u are trying to do. How many tables are
there in your dataset 3 or 2?There should be at least three tables in your
case.

Also u want to change a row's table which row belongs to. Rows.Add will
cause an exception like "this row already belongs to a table"... You should
use ImportRow instead of add... And many questions on your question....

--

Thanks,
Yunus Emre ALP÷ZEN
BSc, MCSD.NET

"Christopher Weaver" <we*****@verizon.net> wrote in message
news:uP**************@TK2MSFTNGP14.phx.gbl...
I've writtten the following (which compiles and runs). For some reason,
TaskRows is always empty.

DataRow[] TaskRows;
foreach(DataRow TaskRow in dsTaskActivities.Tables["Tasks"].Rows)
{
TaskRows = TaskRow.GetChildRows(relTaskActivities);
foreach(DataRow dr in TaskRows)
{
dsTaskActivities.Tables["Activity"].Rows.Add(dr);
}
}

I've confirmed that the DataRelation relTaskActivities in TaskActivities
works and that there is data there for it to grab; I've used this
DataRelation to fill a grid using the DA.Fill method. I'm attempting to
use GetChildRows only because I need to use DA.Fill(DataSet, int, int,
string) on the master table because there are too many records to make the
download time practicle over the web.

If anyone can tell me why GetChildRows isn't returning any rows or any
other way to accomplish the same task, I would really appreciated it. One
person suggested using a 'WHERE ... IN' query and I'm considering it, but
it seems like GetChildRows was created for this purpose.

Nov 17 '05 #2

P: n/a
> First of all, u are modifying the collection which u are current iterating
on.
I don't think so. I'm attempting to add to "Activity" while iterating
"Tasks". They are two tables within the same DataSet.

and i could not understand what u are trying to do. How many tables are
there in your dataset 3 or 2?There should be at least three tables in your
case.
I don't see why I need the third table. What I'm trying to do is iterate
through the rows in Tasks while calling GetChildRows using the DataRelation
that defines the relationship between Tasks and Activity. The purpose of
GetChildRows, as I understand it, is to retrieve just those rows that belong
in Activity given those rows that are already in Tasks.

Also u want to change a row's table which row belongs to. Rows.Add will
cause an exception like "this row already belongs to a table"... You
should use ImportRow instead of add... And many questions on your
question....


I really appreciate this insight and will investigate the usage of ImportRow
at once. Thank you very much for this.

Nov 17 '05 #3

P: n/a
hi,

GetChildRows does what you want, so you should concentrate in what you are
missing.
What tables does relTaskActivities link?

I hope it's not Tasks & Activity :)

you also said that you download only part of the table, of which table?
Tasks or activities?

you may miss part of the activities when you load only a part of it.

my advise would be load a part of Tasks , and nothing from Activities, when
needed just load the activities of the task you are accesing.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Christopher Weaver" <we*****@verizon.net> wrote in message
news:uP**************@TK2MSFTNGP14.phx.gbl...
I've writtten the following (which compiles and runs). For some reason,
TaskRows is always empty.

DataRow[] TaskRows;
foreach(DataRow TaskRow in dsTaskActivities.Tables["Tasks"].Rows)
{
TaskRows = TaskRow.GetChildRows(relTaskActivities);
foreach(DataRow dr in TaskRows)
{
dsTaskActivities.Tables["Activity"].Rows.Add(dr);
}
}

I've confirmed that the DataRelation relTaskActivities in TaskActivities
works and that there is data there for it to grab; I've used this
DataRelation to fill a grid using the DA.Fill method. I'm attempting to
use GetChildRows only because I need to use DA.Fill(DataSet, int, int,
string) on the master table because there are too many records to make the
download time practicle over the web.

If anyone can tell me why GetChildRows isn't returning any rows or any
other way to accomplish the same task, I would really appreciated it. One
person suggested using a 'WHERE ... IN' query and I'm considering it, but
it seems like GetChildRows was created for this purpose.

Nov 17 '05 #4

P: n/a
> my advise would be load a part of Tasks , and nothing from Activities,
when needed just load the activities of the task you are accesing.
This is it exactly. Tasks is much too big for VPN or web access to be
practical. So I'm using DA.Fill(DataSet, int, int, string) to get a finite
set of the rows. Then, I intend to use GetChildRows with the DataRelation
relTaskActivities (yes it links Tasks and Activity) to get just those rows
from Activity that are details of the downloaded Tasks rows.

How do I get this to work!?

And, just in case you're wondering:

//Create DataRelation within dsTaskActivities
//Get the DataColumn objects from the two DataTable objects in
dsTaskActivities.
parentCol = dsTaskActivities.Tables["Tasks"].Columns["uidTask"];
childCol = dsTaskActivities.Tables["Activity"].Columns["uidTask"];
//Create a DataRelation and add it to the DataSet
relTaskActivities = new DataRelation("TaskActivities", parentCol, childCol);
dsTaskActivities.Relations.Add(relTaskActivities);

Thanks.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:uz*************@tk2msftngp13.phx.gbl... hi,

GetChildRows does what you want, so you should concentrate in what you are
missing.
What tables does relTaskActivities link?

I hope it's not Tasks & Activity :)

you also said that you download only part of the table, of which table?
Tasks or activities?

you may miss part of the activities when you load only a part of it.

my advise would be load a part of Tasks , and nothing from Activities,
when needed just load the activities of the task you are accesing.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Christopher Weaver" <we*****@verizon.net> wrote in message
news:uP**************@TK2MSFTNGP14.phx.gbl...
I've writtten the following (which compiles and runs). For some reason,
TaskRows is always empty.

DataRow[] TaskRows;
foreach(DataRow TaskRow in dsTaskActivities.Tables["Tasks"].Rows)
{
TaskRows = TaskRow.GetChildRows(relTaskActivities);
foreach(DataRow dr in TaskRows)
{
dsTaskActivities.Tables["Activity"].Rows.Add(dr);
}
}

I've confirmed that the DataRelation relTaskActivities in TaskActivities
works and that there is data there for it to grab; I've used this
DataRelation to fill a grid using the DA.Fill method. I'm attempting to
use GetChildRows only because I need to use DA.Fill(DataSet, int, int,
string) on the master table because there are too many records to make
the download time practicle over the web.

If anyone can tell me why GetChildRows isn't returning any rows or any
other way to accomplish the same task, I would really appreciated it.
One person suggested using a 'WHERE ... IN' query and I'm considering it,
but it seems like GetChildRows was created for this purpose.


Nov 17 '05 #5

P: n/a
hi,

GetChildRows works with rows that you pulled already, for it to work you
have to pull ALL the rows before hand, exactly what you are trying to avoid.

Just create two queries, one to get the primary table ( or maybe a subset
only ) and other to get the childs of the selected row, this will provoke
more queries to the DB but should improve the overall performance.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Nov 17 '05 #6

P: n/a
If I understand you correctly, I should query a portion of the master table
records, then query the detail records that link to the subset of the master
rows downloaded. This makes sense, but what is the best method of
determining whether or not the detail rows have been downloaded previously
for a specific master row? My system allows the user to jump about and
change the sort order for the master table.

Thanks.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:e8**************@TK2MSFTNGP12.phx.gbl...
hi,

GetChildRows works with rows that you pulled already, for it to work you
have to pull ALL the rows before hand, exactly what you are trying to
avoid.

Just create two queries, one to get the primary table ( or maybe a subset
only ) and other to get the childs of the selected row, this will provoke
more queries to the DB but should improve the overall performance.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Nov 17 '05 #7

P: n/a
no,

You query a part of the master, then WHEN needed you retrieve the part of
the secondary , this will happen when a row of the master is selected.

if later you select another master you load the new details and discard the
old ones.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
If I understand you correctly, I should query a portion of the master
table records, then query the detail records that link to the subset of
the master rows downloaded. This makes sense, but what is the best method
of determining whether or not the detail rows have been downloaded
previously for a specific master row? My system allows the user to jump
about and change the sort order for the master table.

Thanks.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:e8**************@TK2MSFTNGP12.phx.gbl...
hi,

GetChildRows works with rows that you pulled already, for it to work you
have to pull ALL the rows before hand, exactly what you are trying to
avoid.

Just create two queries, one to get the primary table ( or maybe a subset
only ) and other to get the childs of the selected row, this will provoke
more queries to the DB but should improve the overall performance.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


Nov 17 '05 #8

P: n/a
OK. One last question.

From what you've said I gather that the user or the system must either
commit or discard any changes made to the detail rows before the user is
allowed to depart the current master row. Is that your approach?

Thanks again.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:%2****************@tk2msftngp13.phx.gbl...
no,

You query a part of the master, then WHEN needed you retrieve the part of
the secondary , this will happen when a row of the master is selected.

if later you select another master you load the new details and discard
the old ones.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
If I understand you correctly, I should query a portion of the master
table records, then query the detail records that link to the subset of
the master rows downloaded. This makes sense, but what is the best
method of determining whether or not the detail rows have been downloaded
previously for a specific master row? My system allows the user to jump
about and change the sort order for the master table.

Thanks.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:e8**************@TK2MSFTNGP12.phx.gbl...
hi,

GetChildRows works with rows that you pulled already, for it to work you
have to pull ALL the rows before hand, exactly what you are trying to
avoid.

Just create two queries, one to get the primary table ( or maybe a
subset only ) and other to get the childs of the selected row, this will
provoke more queries to the DB but should improve the overall
performance.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



Nov 17 '05 #9

P: n/a
hi,

you said nothing about the data changing in the client app, if you change it
you should update the DB of course.

if the data is not changed then you have two options, either discard the
current details rows and get the new set, or just get the new set of details
rows and just append to the details table.
The later approach will make it faster if the client reselect a previously
selected master, it's already in the client table and not need to go to the
db to get an update. ( of course you will not get any update made in the DB
from the time you first got it )
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:ul**************@TK2MSFTNGP10.phx.gbl...
OK. One last question.

From what you've said I gather that the user or the system must either
commit or discard any changes made to the detail rows before the user is
allowed to depart the current master row. Is that your approach?

Thanks again.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:%2****************@tk2msftngp13.phx.gbl...
no,

You query a part of the master, then WHEN needed you retrieve the part of
the secondary , this will happen when a row of the master is selected.

if later you select another master you load the new details and discard
the old ones.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
If I understand you correctly, I should query a portion of the master
table records, then query the detail records that link to the subset of
the master rows downloaded. This makes sense, but what is the best
method of determining whether or not the detail rows have been
downloaded previously for a specific master row? My system allows the
user to jump about and change the sort order for the master table.

Thanks.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
wrote in message news:e8**************@TK2MSFTNGP12.phx.gbl...
hi,

GetChildRows works with rows that you pulled already, for it to work
you have to pull ALL the rows before hand, exactly what you are trying
to avoid.

Just create two queries, one to get the primary table ( or maybe a
subset only ) and other to get the childs of the selected row, this
will provoke more queries to the DB but should improve the overall
performance.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



Nov 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.