Click here to Skip to main content
15,070,089 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
HI All,

i have a table which needs to store values like -562,000.00 in one of its columns. i have declared the field type to be numeric(18,2) for that column. I am trying to update that columns using a Stored Procedure but wheni add parameters to the command object from code as
comm1.Parameters.Add("@Excl", SqlDbType.Decimal).Value = Convert.ToDecimal(objDataSet.Tables[0].Rows[i]["Excl"]);

I am getting an error.

What is the Datatype i should be using here?

Updated 26-Sep-11 0:22am
Mehdi Gholam 26-Sep-11 4:51am
What is the error you are getting?
AnnSJ 26-Sep-11 5:23am
Input string is not in correct format.
it happens when the Convert.ToDecimal( is happening.
Om Prakash Pant 26-Sep-11 7:25am
the value of objDataSet.Tables[0].Rows[i]["Excl"] is -562,000.00? and what is the datatype of this column?

1 solution

Use single it will work

comm1.Parameters.Add("@Excl",  SqlDbType.Decimal).Value = Convert.Single(objDataSet.Tables[0].Rows[i]["Excl"]);


comm1.Parameters.Add("@Excl",  SqlDbType.Float).Value = Convert.Single(objDataSet.Tables[0].Rows[i]["Excl"]);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900