Column auto value

Last post 10-24-2007 5:45 PM by jbear123. 5 replies.

Sort Posts:

  • Column auto value

    10-24-2007, 4:08 PM
    • Member
      279 point Member
    • jbear123
    • Member since 10-08-2007, 11:02 AM
    • Posts 899

    Hi,

    I am using vwd 05. I have a table, and I want a column to have default value of a sum of 2 others. e.g: column4 = column1 + (column2 * column3)

    Where would I write this so the columns value is set automatically using the sum?

     

    Thanks,

    Jon 

  • Re: Column auto value

    10-24-2007, 4:49 PM
    • Member
      272 point Member
    • niravpatel5
    • Member since 10-10-2007, 11:52 PM
    • Posts 106

     

     which table you are taking about database table, or just creating runtime table using table property...????

     if you are using table property,then use like

    cell_2 =
    New TableCellcell_2.Text = Convert.ToDouble(TotalSalesFromB2direct - TotalFunding2).ToString("C")

    cell_2.HorizontalAlign = HorizontalAlign.Right

    cell_2.BorderStyle = BorderStyle.Dashed

    cell_2.BorderWidth = 1

    cell_2.Font.Bold = True

    tr_2.Cells.Add(cell_2)

    let me know if that doesn't work

    If this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.
    That way future readers will know which post solved your issue.
  • Re: Column auto value

    10-24-2007, 5:07 PM
    • Member
      279 point Member
    • jbear123
    • Member since 10-08-2007, 11:02 AM
    • Posts 899

     Hi, thanks for your reply!

    I was actually talking about a database table - static thats always there..

     

    Thanks,

    Jon
     

  • Re: Column auto value

    10-24-2007, 5:30 PM
    • Member
      272 point Member
    • niravpatel5
    • Member since 10-10-2007, 11:52 PM
    • Posts 106

    You would need a trigger to add data to User_Data when a new row is
    added to aspnet_users:

       CREATE TRIGGER add_user_data ON aspnet_Users FOR INSERT AS
        INSERT User_Data(UserID, Level, Points, ...)
           SELECT UserID, 1, 0, --- more defaults goes here
           FROM   inserted

     

    or use just formula in insert statement argument like..

    dim z as integer =x+y

    insert into a values (x,y,z)

    If this has helped Please: Don't forget to click "Mark as Answer" on the post that helped you.
    That way future readers will know which post solved your issue.
  • Re: Column auto value

    10-24-2007, 5:31 PM
    • Member
      152 point Member
    • yvzman
    • Member since 05-07-2007, 7:35 PM
    • Turkey
    • Posts 36

    In the database side you can do it with the following script;

    select col1+(col2 * col3) as col 4 from yourtable

    But actually i could not understand if you are talking about this.

     

    Or in the application side (i assume you have a datatable filled with the results) you can add a computed column as;

    for example dt is your datatable in your dataset, and you want to add a computed column;

    dt.Columns.Add("col4", GetType(Integer), "col1 + (col2 * col3)") in vb.net

     dt.Columns.Add("col4", typeof(int), "col1 + (col2 * col3)") in c#

     

     

     

    Yavuz Küçükpetek
    http://www.dotnetgurus.net
  • Re: Column auto value

    10-24-2007, 5:45 PM
    • Member
      279 point Member
    • jbear123
    • Member since 10-08-2007, 11:02 AM
    • Posts 899

     Hi,

    I am using VWD 05..

    I am looking at tables - click 'open table definitions' - where you make tables and define their data type..

    I noticed in the column properties there is a 'default value or binding' section - I thought maybe I could type in some code there to make all entrys of the column the sum of other columns?

    Or is there another way to do it permenantly through vwd backend?

    Thanks,

    Jon 

Page 1 of 1 (6 items)