Expression Column based on another expression column - Is this possible?

A

APops

Hi all,

I have just started working with ADO.NET and VB.NET and have a
question.

I have three DataTables with DataRelations set up between them.

The first table contains a column called PercentWeight.
The second table contains a column called SubGroupWeight with the
expression "sum(child.PercentWeight)"
The third table contains a column called GroupWeight with the
expression "sum(child.SubGroupWeight)"
When I view the whole DataSet in a datagrid, I get nulls in the
expression column GroupWeight in the third table.
Is this expected behavior?

Thanks for any help.
Andrew Pop.
 
M

Mary Chipman [MSFT]

I think what you're going to need to do here is compute the first
expression in the underlying query before prior to the DataSet and
then you can have the second expression based on that column. I can't
see how you can get it to work otherwise. FWIW, you'll probably get
more of a performance boost if you can perform as much of your
processing on the server as possible instead of in your client code.

--Mary
 
A

APops

Hi Mary,

Thanks for your reply and your time. I do try to complete as much
processing as possible on the server. The application that I am
developing reads data from a sp that returns multiple datatables. The
data is read into one dataset. After the read, the db is no longer
needed. The application uses this data from the sp to generate
weightings. I would like to calculate sub-category weights and
category weights within existing tables in the dataset. I can get it
to work if I re-set the expression after the weights change. Should I
need to do this? Can I get a dataset with expression based columns to
act like a spreadsheet(ie, A1+A2=A3 can I get A3 to change if I change
A1 where A2 is an expression column?)

Cheers,
Andrew Pop.
 
M

Mary Chipman [MSFT]

It would be better to do as much calculation as possible in the stored
procedure that returns the result sets to the datatables. As far as
getting the dataset/datatable to act like XL, then the answer is no.
However, you should check out doing it in a data control, that is an
option I'm not that up to speed on.

--Mary
 

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