# Thread: How to formulate an expression for a calculated datatable column

1. ## How to formulate an expression for a calculated datatable column

I an writing an application with an untyped dataset. The dataset has 3 tables.
Two of the tables will have 5 columns and only one row. They contain numeric data that I will use in the third table to perform some calculations.
Table three will have 10 columns and as many as 20 rows. Five of the columns of Table3 contain numeric data entered by the user and 5 of the columns will hold calculated data. If no parent-child relationship exists between the tables is there a way to code the expression for the calculated columns to reference columns in the other two tables.

I've tried using Table1.ColumnName * Table3ColumnName but this won't complie.

Can anyone give me any suggestions?

2. ## Re: How to formulate an expression for a calculated datatable column

what sort of calculations?

maybe... poll the fields you need, perform calculations, combine w/user data, and then update table 3?

3. ## Re: How to formulate an expression for a calculated datatable column

I suppose my question is this: Is it necessary to establish a relationship between the tables to reference columns from other two tables in the expression used to calculate a column value in the third table.

4. ## Re: How to formulate an expression for a calculated datatable column

Originally Posted by danhollier
I suppose my question is this: Is it necessary to establish a relationship between the tables to reference columns from other two tables in the expression used to calculate a column value in the third table.
No; you use relationships to enforce referential integrity.

5. ## Re: How to formulate an expression for a calculated datatable column

Then if it is not necessary to have a parent-child relationship with the tables, what would be the correct syntax of the expression for a calculated column in table3 that does the following:

Table2.Column1Value * Table3.Column3Value

This would be the expression to calculate the value in Table3's Column5

6. ## Re: How to formulate an expression for a calculated datatable column

Originally Posted by danhollier
Then if it is not necessary to have a parent-child relationship with the tables, what would be the correct syntax of the expression for a calculated column in table3 that does the following:

Table2.Column1Value * Table3.Column3Value

This would be the expression to calculate the value in Table3's Column5
That would depend on what DBMS you are using...SQL Server, Oracle, MySQL, what?

7. ## Re: How to formulate an expression for a calculated datatable column

The dataset will be untyped. Not connected to any DB backend. I'm using the DataSet instead of an ArrayList to make persisting the data to disk easier. I'll be using the write/read XML of the dataset to do this. I'm new to VB.Net, I'm more familiar with Delphi. Also is there a way to do more complex math calculations in an event of the datatable.

8. ## Re: How to formulate an expression for a calculated datatable column

Originally Posted by danhollier
The dataset will be untyped. Not connected to any DB backend. I'm using the DataSet instead of an ArrayList to make persisting the data to disk easier. I'll be using the write/read XML of the dataset to do this. I'm new to VB.Net, I'm more familiar with Delphi. Also is there a way to do more complex math calculations in an event of the datatable.
Sorry, I can't help you with that; I don't use VB.NET. Since you're not actually using a database I'd suggest you ask this question in the VB.NET forum.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Featured