Skip to content

How to roundup Excel sheet float value in to sqlserver query

deepa ashwi

Asked Jun 30, 2013, 8:07 AM EDT1 answer
Share
LinkedInX
i am importing data from Excel to SQL Server database. 
 
how to convert a float value in excel to round up value in SQl Query. i need to convert here the Basic Salary from float value into Round Up value(when passing to database). 
 

Code
string ins = "insert into PaySalary1(BasicSalary,HRA)values
('" + Convert.ToDecimal(dtExcel.Rows[i][0]) + "','" + dtExcel.Rows[i][1] + "')";

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Sunny  Sharma
    0
    Hi Deepa,

    You can use Math.Abs() to round up the decimal values, like:
    ---------------------------------------

    Code
    string ins = "insert into PaySalary1(BasicSalary,HRA)values ('" + Math.Abs(Convert.ToDecimal(dtExcel.Rows[i][0])) + "','" + dtExcel.Rows[i][1] + "')";


    Happy Coding :)

    Mark it as answer if it helps you.
    Cheers!
    0