Relate to a nonprimary key column

F

Fred

Hi,

Is it possible to bind a column in a table to a column in another table if
the columns are not a primary key.
I'll describe what I'm trying to do here.

One dataset.
Two tables - Job and Invoice
They are related through a DataRelation object with their primary and
foreign keys.
Job is the datasource of a DataGrid.
The grid displays info about jobs. I also want to display the date when a
possible related invoice was created.
(If such an invoice can't be found I display a default value.)

I preferrably don't want to solve this problem with my sql-statements.

Can I create a sort of lookup-column?

Thank you,

Fred
 
M

Miha Markic [MVP C#]

Hi Fred,

You might take a look at DataColumn.Expression property if I understand
correctly your problem.
 
F

Fred

Thanx for your advice Miha,

The problem is that when using aggregates the value is computed. What i want
is a reference to the child column, so that if the childrow is changed,
deleted, or if a childrow is inserted then the value in the parent column is
changed to.

Any advice?

(I'm new to .Net, recently migrating from Delphi where you can create lookup
fields. I think that's the kind of functionality I'm looking for...)

Fred

Miha Markic said:
Hi Fred,

You might take a look at DataColumn.Expression property if I understand
correctly your problem.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Fred said:
Hi,

Is it possible to bind a column in a table to a column in another table if
the columns are not a primary key.
I'll describe what I'm trying to do here.

One dataset.
Two tables - Job and Invoice
They are related through a DataRelation object with their primary and
foreign keys.
Job is the datasource of a DataGrid.
The grid displays info about jobs. I also want to display the date when a
possible related invoice was created.
(If such an invoice can't be found I display a default value.)

I preferrably don't want to solve this problem with my sql-statements.

Can I create a sort of lookup-column?

Thank you,

Fred
 
M

Miha Markic [MVP C#]

Hi Fred,

I don't think that you are after a lookup. Instead, you might add a column
to the Job table (that holds the same value as Invoice value you are
interested in - copy the values). And when the value of new column changes
you might propagate it to Invoice value, by using JobsTable.RowChanged event
perhaps.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Fred said:
Thanx for your advice Miha,

The problem is that when using aggregates the value is computed. What i want
is a reference to the child column, so that if the childrow is changed,
deleted, or if a childrow is inserted then the value in the parent column is
changed to.

Any advice?

(I'm new to .Net, recently migrating from Delphi where you can create lookup
fields. I think that's the kind of functionality I'm looking for...)

Fred

Miha Markic said:
Hi Fred,

You might take a look at DataColumn.Expression property if I understand
correctly your problem.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Fred said:
Hi,

Is it possible to bind a column in a table to a column in another
table
when
 

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