Expression column and DataBinding

S

Sébastien

Hi,

I have a composed primary key (2 fields) in a table and I have a child
who have the 2 fields as foreign key. I created an expression column in my 2
tables to combine my 2 primary key fields in one (Column1 + ' ' + Column2).
In my VB form, I did my DataBinding as follow (on a ComboBox) :


DataSource = myDataSet
DisplayMember = String field from my parent table
ValueMember = Expression column from my parent column
SelectedValue = Expression column from my child table (the actual one)


When I do a myDataSet.Tables(ChildTable).CancelChanges(), it don't cancel
the change I did in my ComboBox. It only works when I do my DataBinding on a
field that already exists in my DataBase (I always do my DataBinding on
primary keys).

Maybe there is a better way to do what I am trying to do, so let me know if
you have a better solution.

Thank you for your help.
 
M

Miha Markic

Hi,

I would avoid expressions as they are good only for readonly data IMO.
Rather, I would set values manually.
 
S

Sébastien

Thank you for your first answer.

Could you give me an example of what you mean ? Or just give me a little bit
more detail ?

Thank you.
 
S

Sébastien

Ok, I understood what you meant and it work perfectly now.

If you know a better way to reach my goal without setting values manually,
please let me know, because I would not like my software to become slower
and slower each time I add more records in my database.

Thank you for your help.
 
N

Nauzad Kapadia

that depends on how you are doing it.

i would typically trap the "column_changed" event of the datatable for my
calculated columns.

regards,
Nauzad Kapadia [MVP]
 

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