Solved

Adding a calculated column to datatable based on Parent field.

Posted on 2004-04-17
2
1,330 Views
Last Modified: 2008-01-16
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-custOrder", ds.Tables("Customer").Columns(0),                                                 ds.Tables("custOrders").Columns(1))

ds.Relations.Add(r)

'Add Column
ds.Tables("custOrders").Columns.Add("cName", GetType(String), "Parent(Customer-custOrder).customerName")

'Add Binding
lblCust.DataBindings.Add("Text", ds, "custOrders.cName")

The problem is with "Parent(Customer-custOrder).customerName"
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_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
0
Comment
Question by:Tiare
2 Comments
 
LVL 3

Accepted Solution

by:
Lektran earned 500 total points
Comment Utility
have you tried taking the '-' out of the relation name?
0
 

Author Comment

by:Tiare
Comment Utility
Haha, so simple.

Thanks mate.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now