Tiare
asked on
Adding a calculated column to datatable based on Parent field.
Hi,
I'm trying to create a calculated column in a datatable which puts in the value of a field from a parent table.
I'm working with the following tables from my db: custOrders, Customer
Essentially I just want to bind a combo box to the customerName field which is Parent in the relation with custOrders.
Code:
'Add Relationship
r = New DataRelation("Customer-cus tOrder", ds.Tables("Customer").Colu mns(0), ds.Tables("custOrders").Co lumns(1))
ds.Relations.Add(r)
'Add Column
ds.Tables("custOrders").Co lumns.Add( "cName", GetType(String), "Parent(Customer-custOrder ).customer Name")
'Add Binding
lblCust.DataBindings.Add(" Text", ds, "custOrders.cName")
The problem is with "Parent(Customer-custOrder ).customer Name"
It complains when I try to specify the relationship name (like I have here). If I have only one parent relationship on the custOrders table then I don't need to specify the relationship name and it works - but I have more than one parent relationship.
The error is:
Syntax error in Lookup expression: Expecting keyword 'Parent' followed by a single column argument with possible relation qualifier: Parent[(<relation_name>)]. <column_na me>.
I have tried putting the relationship name in quotes and I get the same error.
Is there a better way to bind to the parent field, or how can I get the column add function to work?
Thanks
I'm trying to create a calculated column in a datatable which puts in the value of a field from a parent table.
I'm working with the following tables from my db: custOrders, Customer
Essentially I just want to bind a combo box to the customerName field which is Parent in the relation with custOrders.
Code:
'Add Relationship
r = New DataRelation("Customer-cus
ds.Relations.Add(r)
'Add Column
ds.Tables("custOrders").Co
'Add Binding
lblCust.DataBindings.Add("
The problem is with "Parent(Customer-custOrder
It complains when I try to specify the relationship name (like I have here). If I have only one parent relationship on the custOrders table then I don't need to specify the relationship name and it works - but I have more than one parent relationship.
The error is:
Syntax error in Lookup expression: Expecting keyword 'Parent' followed by a single column argument with possible relation qualifier: Parent[(<relation_name>)].
I have tried putting the relationship name in quotes and I get the same error.
Is there a better way to bind to the parent field, or how can I get the column add function to work?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks mate.