473,386 Members | 1,699 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,386 software developers and data experts.

DataRelations?

Hi All

this is going to be a lengthy questions do please bear
with me....

I have a database that has three tables - Employees,
ShiftHeader,ShiftDetails

Now the employees table holds the ShiftID for the
ShiftHeader table, to determine which shif t the employee
belongs to, As for the ShiftHeader table it has the
ShiftID, and a bunch of other information relating the
the Shift as a whole. Now for the ShiftDetails, this
holds detailed info about the specific ShiftID So in
other words my relationships look like this :

Employee ShiftHeader
ShiftDetails
ShiftID (Many-------1) ShiftID (1----Many) ShiftID

(Sorry for the disgusting diagrams!)

But my problem is the following:

I have a Datarow that I have declared inside a foreach
loop that cycles through all the employees. This Datarow
is set to retrieve the Parentrow(ShiftID from
ShiftHeader) eg

foreach(DataRow drEmp in Dataset.Tables["Employees"].rows)
{
DataRow drShiftHeader
drShiftHeader = drEmp.GetParentRow(EmpShiftHeadRel);
//do dome work with the drShiftHeader

}

Now that goes well and I can cycle through the
drShiftHeader columns and Debug.Write the data, but I
cannot seem to get the Child rows of the drShiftHeader
DataRow eg

foreach(Datarow drEmp in Dataset.Tables["Employees"].rows)
{
DataRow drShiftHeader
DataRow[] drShiftDetails
drShiftHeader = drEmp.GetParentRow(EmpShiftHeadRel);
//do dome work with the drShiftHeader
drShiftDetails = drShiftHeader.GetChildRows
(ShiftHeadertoShiftDetailsRel);
//drShiftDetails.Length = 0!

}
Can anyone direct me what to do in order for me to
retrieve the child rows of the parent row I have just
gotten? What am I doing wrong here?

Thanks for nay help - it is much appreciated

Kevin
Nov 15 '05 #1
3 3426
You did not give the code which build the relations. If I were you I will
first check that code make sure I put the columns at right sequence in the
constructor arguments. first column is parent and sencond column is child.

Hope this will help.
"Kevin" <an*******@discussions.microsoft.com> wrote in message
news:02****************************@phx.gbl...
Hi All

this is going to be a lengthy questions do please bear
with me....

I have a database that has three tables - Employees,
ShiftHeader,ShiftDetails

Now the employees table holds the ShiftID for the
ShiftHeader table, to determine which shif t the employee
belongs to, As for the ShiftHeader table it has the
ShiftID, and a bunch of other information relating the
the Shift as a whole. Now for the ShiftDetails, this
holds detailed info about the specific ShiftID So in
other words my relationships look like this :

Employee ShiftHeader
ShiftDetails
ShiftID (Many-------1) ShiftID (1----Many) ShiftID

(Sorry for the disgusting diagrams!)

But my problem is the following:

I have a Datarow that I have declared inside a foreach
loop that cycles through all the employees. This Datarow
is set to retrieve the Parentrow(ShiftID from
ShiftHeader) eg

foreach(DataRow drEmp in Dataset.Tables["Employees"].rows)
{
DataRow drShiftHeader
drShiftHeader = drEmp.GetParentRow(EmpShiftHeadRel);
//do dome work with the drShiftHeader

}

Now that goes well and I can cycle through the
drShiftHeader columns and Debug.Write the data, but I
cannot seem to get the Child rows of the drShiftHeader
DataRow eg

foreach(Datarow drEmp in Dataset.Tables["Employees"].rows)
{
DataRow drShiftHeader
DataRow[] drShiftDetails
drShiftHeader = drEmp.GetParentRow(EmpShiftHeadRel);
//do dome work with the drShiftHeader
drShiftDetails = drShiftHeader.GetChildRows
(ShiftHeadertoShiftDetailsRel);
//drShiftDetails.Length = 0!

}
Can anyone direct me what to do in order for me to
retrieve the child rows of the parent row I have just
gotten? What am I doing wrong here?

Thanks for nay help - it is much appreciated

Kevin

Nov 15 '05 #2
You did not give the code which build the relations. If I were you I will
first check that code make sure I put the columns at right sequence in the
constructor arguments. first column is parent and sencond column is child.

Hope this will help.
"Kevin" <an*******@discussions.microsoft.com> wrote in message
news:02****************************@phx.gbl...
Hi All

this is going to be a lengthy questions do please bear
with me....

I have a database that has three tables - Employees,
ShiftHeader,ShiftDetails

Now the employees table holds the ShiftID for the
ShiftHeader table, to determine which shif t the employee
belongs to, As for the ShiftHeader table it has the
ShiftID, and a bunch of other information relating the
the Shift as a whole. Now for the ShiftDetails, this
holds detailed info about the specific ShiftID So in
other words my relationships look like this :

Employee ShiftHeader
ShiftDetails
ShiftID (Many-------1) ShiftID (1----Many) ShiftID

(Sorry for the disgusting diagrams!)

But my problem is the following:

I have a Datarow that I have declared inside a foreach
loop that cycles through all the employees. This Datarow
is set to retrieve the Parentrow(ShiftID from
ShiftHeader) eg

foreach(DataRow drEmp in Dataset.Tables["Employees"].rows)
{
DataRow drShiftHeader
drShiftHeader = drEmp.GetParentRow(EmpShiftHeadRel);
//do dome work with the drShiftHeader

}

Now that goes well and I can cycle through the
drShiftHeader columns and Debug.Write the data, but I
cannot seem to get the Child rows of the drShiftHeader
DataRow eg

foreach(Datarow drEmp in Dataset.Tables["Employees"].rows)
{
DataRow drShiftHeader
DataRow[] drShiftDetails
drShiftHeader = drEmp.GetParentRow(EmpShiftHeadRel);
//do dome work with the drShiftHeader
drShiftDetails = drShiftHeader.GetChildRows
(ShiftHeadertoShiftDetailsRel);
//drShiftDetails.Length = 0!

}
Can anyone direct me what to do in order for me to
retrieve the child rows of the parent row I have just
gotten? What am I doing wrong here?

Thanks for nay help - it is much appreciated

Kevin


Nov 15 '05 #3
Kevin,

You're going to have to establish a Datarelation.

pseudo-code:

DataRelation oRelation = new
DataRelation(strRelationName,dataset.parentTable.P arentcolumn,
dataset.childTable.ChildColumn);

dataset.Relations.Add(oRelation);

check the docs for exact systax, but this should get you started. Once this
is done, you should get results back when doing a row.getChildRows() method.

hth,

Marco
"Kevin" <an*******@discussions.microsoft.com> wrote in message
news:02****************************@phx.gbl...
Hi All

this is going to be a lengthy questions do please bear
with me....

I have a database that has three tables - Employees,
ShiftHeader,ShiftDetails

Now the employees table holds the ShiftID for the
ShiftHeader table, to determine which shif t the employee
belongs to, As for the ShiftHeader table it has the
ShiftID, and a bunch of other information relating the
the Shift as a whole. Now for the ShiftDetails, this
holds detailed info about the specific ShiftID So in
other words my relationships look like this :

Employee ShiftHeader
ShiftDetails
ShiftID (Many-------1) ShiftID (1----Many) ShiftID

(Sorry for the disgusting diagrams!)

But my problem is the following:

I have a Datarow that I have declared inside a foreach
loop that cycles through all the employees. This Datarow
is set to retrieve the Parentrow(ShiftID from
ShiftHeader) eg

foreach(DataRow drEmp in Dataset.Tables["Employees"].rows)
{
DataRow drShiftHeader
drShiftHeader = drEmp.GetParentRow(EmpShiftHeadRel);
//do dome work with the drShiftHeader

}

Now that goes well and I can cycle through the
drShiftHeader columns and Debug.Write the data, but I
cannot seem to get the Child rows of the drShiftHeader
DataRow eg

foreach(Datarow drEmp in Dataset.Tables["Employees"].rows)
{
DataRow drShiftHeader
DataRow[] drShiftDetails
drShiftHeader = drEmp.GetParentRow(EmpShiftHeadRel);
//do dome work with the drShiftHeader
drShiftDetails = drShiftHeader.GetChildRows
(ShiftHeadertoShiftDetailsRel);
//drShiftDetails.Length = 0!

}
Can anyone direct me what to do in order for me to
retrieve the child rows of the parent row I have just
gotten? What am I doing wrong here?

Thanks for nay help - it is much appreciated

Kevin

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Les | last post by:
I have a problem getting Dataset.WriteXml() to create a nested xml realtionship. All I get is an inline xsd (all nodes are children of the root). Documentation says to use...
4
by: niv | last post by:
Hi, I am unsure on how to retrieve data from tables 2 tables that are related through a relationship table.. TableOne -------- TableOneID TableOneDesc
0
by: Randy | last post by:
I have two DataTables in a DataSet. I create a DataRelation between two like-typed columns in the first and second tables, and it works exactly as expected. Unfortunately, the default behavior...
1
by: Fleckman | last post by:
I have a DataSet with 14 DataTables and 18 Relationships that were defined within Visual Studio .NET 2003. Everything looks OK in the visual development environment, i.e. when I preview the DataSet...
2
by: Phil Townsend | last post by:
I have seen a lot on ADO.NET data relations, but my jury is still out on the benefits of coding a data relation vs. using a join in a stored procedure. I know there is more overhead when using the...
1
by: Lerp | last post by:
Hi all, I have a dataset made up of 3 tables that is bound to a datalist. On the itemdataBound event I call a sub that grabs a value (an id value) from the current row being outputted, queries...
0
by: George Durzi | last post by:
I have a DataSet with 3 tables, and two DataRelations dsSubs.Tables.TableName = "Subscriptions" dsSubs.Tables.TableName = "AccountManagers" dsSubs.Relations.Add "AccountManagers_Subscriptions",...
3
by: Carlos Albert | last post by:
Hello everybody, I'm using some gridviews with datalists inside template columns. Now, for each datalist I'm calling a method returning a dataset (depending from a column from the gridview). ...
0
by: Vajrala Narendra | last post by:
hi all, am working in asp.net i am using two data entry screens for parent and child tables. i heard that using datarelations we can achieve this using single screen. is it ppossible? please...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.