ado_dotnet thread: Subject: Problem adding a column with reference to a column in a child table.
Hello, I have a question:
I have to tables: Units and Tasks
The Tasks table, has a field UnitID (integer), that holds an ID of a record
in Units table. A Task may have a unit asigned to it.
I fill a dataset with both tables and create a relationship between them,
the parent column is Tasks.UnitID and the child column is Unit.ID.
ParentCol = Ds.Tables("Tasks").Columns("UnitID")
ChildCol = Ds.Tables("Units").Columns("ID")
Ds.Relations.Add("TaskUnit", ParentCol, ChildCol, False)
The false paramenter means no create constraints.
Then I try to add a new column to Tasks table with a reference to column
Name in Units table.
WITH m_DS.Tables("Tasks").Columns.Add("UnitName")
.Expression = "Child.Name"
End With
I receive the error:
An unhandled exception of type 'System.Data.SyntaxErrorException' occurred
in system.data.dll
Additional information: Cannot interpret token 'Child' at position 1.
What Im doing wrong?
**** TAKEN FROM vb.net HELP
PARENT/CHILD RELATION REFERENCING
A column in a child table may be referenced in an expresion by prepending
the column name with "Child." For example, "Child.Price" would reference
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 Employee and Titles, and the
DataRelation objects are named "Publishers2Employee: and
"Publishers2Titles," the reference would be:
Child(Publishers2Employee).fname
Child(Publishers2Titles).title
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."
*****
Thanks, Santiago Méndez mailto:santiago@i...