473,385 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

GetChildRows

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
9 4894
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
> 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
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
> 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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ben R. | last post by:
Could someone fill me in on the difference between the following three DataRow methods: GetParentRow GetParentRows GetChildRows I'm guessing the difference between the first two is that one...
3
by: I am Sam | last post by:
I can relate two tables rather easily using the following code: dsClub.Relations.Add("Section_Data", dsClub.Tables.Columns, dsClub.Tables.Columns); Which connects the "Section" table to the...
8
by: I am Sam | last post by:
Hi everyone, This problem is making me old. I don't want to get any older. I have a multi-nested repeater control as follows: <asp:Repeater ID="clubRep1" Runat="server">...
5
by: Geoff Jones | last post by:
Hi How can I search, using SQL commands, an arrow of rows generated from GetChildRows. For example, suppose the result is given by: Dim drMyRows() As DataRow =...
2
by: Joe | last post by:
Hi I have a dataset with 3 tables and 2 relations Is there a way to when I am at 1 row to tell if there is a relation on that row ??? I have the code hardcoded but try to make it work if the #...
2
by: G .Net | last post by:
Hi A question has just occurred to me. I can get the child rows in a relationship using GetChildRows. Further, I can do something like: For Each child As DataRow In...
1
by: delusion7 | last post by:
I'm really lost right now, I can't figure out how to pass to values from a table back to the presentationTier. I am searching by the value selected in the parent(carSize) using a comboBox and passing...
4
by: Daniel | last post by:
What's wrong with this code? 1 Dim parentRow, childRow as DataRow 2 3 For i = 0 To mainDataTable.Rows.Count - 1 4 parentRow = mainDataTable.Rows(i) 5 childRow =...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.