none
String function in DataColumn.Expression RRS feed

  • Question

  • Hi,

    I have two columns in dataset, first is integer, second column is also number, but in string format with commas, lile 2,345,564.

     

    I need the multiplication of these two columns in the third column using Expression.

     

    Please help.

     

    Regards,

    Javed Hasnain

     

    Tuesday, February 5, 2008 7:51 AM

Answers

  • You could try to use next expression for your column

     

    "FirstColumnName * CONVERT(SecondColumnName, 'System.Int32')"

     

    but I am not sure if commas would be treated properly during conversion

     

    Tuesday, February 5, 2008 10:32 AM
    Moderator
  • Thanks for the reply...

    This will give error as I have commas in the number. My problem was solved. I used

    "FirstColumnName * CONVERT(SecondColumnName, 'System.Double')"

    While converting to double, it takes care of the commas.

    Wednesday, February 6, 2008 5:45 AM

All replies

  • You could try to use next expression for your column

     

    "FirstColumnName * CONVERT(SecondColumnName, 'System.Int32')"

     

    but I am not sure if commas would be treated properly during conversion

     

    Tuesday, February 5, 2008 10:32 AM
    Moderator
  • Thanks for the reply...

    This will give error as I have commas in the number. My problem was solved. I used

    "FirstColumnName * CONVERT(SecondColumnName, 'System.Double')"

    While converting to double, it takes care of the commas.

    Wednesday, February 6, 2008 5:45 AM