VS2005: DataSet Parent not returning a value

M

mikemiller.innova

In Visual Studio 2005 SP1,

I added a DataSet item into my project.

I added 3 tables from SQL that have data and relationships.

I added 2 lookup columns (lkp) to the DllVersions table in the dataset

[Project]
ProjectID
ProjectName

[Servers]
ServerID
ServerName

[DllVersions]
DllVersionID
ProjectID
ServerID
DllVersion
lkpServerName (not in SQL)
lkpProjectName (not in SQL)


I want the lkp Columns to return the Name from the associated ID in the
parent table.

So in the DataSet, I click properties and set the Expression for
lkpServerName to
Parent(FK_DllVersions_Servers).ServerName

lkpProjectName to
Parent(FK_DllVersions_Projects).ProjectName

I can preview the data for any table in the dataset and it's all there.
The code is working because it does not throw an exception. However, it
does not display any data in either of the lkp columns.

What's going on here?
 
M

Marc Gravell

Wouldn't that just be "Parent.ServerName"?

<q>A parent table may be referenced in an expression by prepending the
column name with Parent. For example, the Parent.Price references the
parent table's column named Price.

A column in a child table may be referenced in an expression by
prepending the column name with Child. However, because child
relationships may return multiple rows, you must include the reference
to the child column in an aggregate function. For example,
Sum(Child.Price) would return the sum of the column named Price in the
child table.

If a table has more than one child, the syntax is: Child(RelationName).
For example, if a table has two child tables named Customers and
Orders, and the DataRelation object is named Customers2Orders, the
reference would be as follows:

Avg(Child(Customers2Orders).Quantity)</q>

http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx

Marc
 
M

mikemiller.innova

Nope...

Parent.ColumnName is for when there is only one relationship on the
table.
 
M

Marc Gravell

Then I stand corrected. I must admit I don't do a lot of DataSet work
and was basing this on the docs (cited).

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top