Results 1 to 8 of 8

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

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    4

    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. #2
    New Member
    Join Date
    Jan 2007
    Posts
    9

    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. #3

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    4

    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. #4
    Hyperactive Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    476

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

    Quote 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. #5

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    4

    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. #6
    Hyperactive Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    476

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

    Quote 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. #7

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    4

    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. #8
    Hyperactive Member
    Join Date
    Oct 2006
    Location
    USA
    Posts
    476

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

    Quote 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
  •  



Click Here to Expand Forum to Full Width