I am trying to insert a record that has decimal place, example: 7654.00 and the data type for this column is numeric(10,12) but I am getting arithmetic overflow error and I know I need to do a conversion first but not sure how..
The column I have the issue with is TotalCost.
Here is what I have:
string FullName = row.Cells[1].Text;
string TotalCost = row.Cells[6].ToString();
using (SqlConnection myCon = new SqlConnection(myConnStr))
{
using (SqlCommand myCmd = new SqlCommand())
{
myCmd.Connection = myCon;
myCmd.CommandType = CommandType.Text;
myCmd.CommandText = @"insert into myTable (FullName, TotalCost)
values(@FullName, @TotalCost)";
myCmd.Parameters.AddWithValue("@FullName", FullName.ToString());
myCmd.Parameters.AddWithValue("@TotalCost", TotalCost)
myCon.Open();
myCmd.ExecuteNonQuery();
myCon.Close();
}
}
TotalCostis numeric, then it needs to be converted to decimal\double and then passed asmyCmd.Parameters.AddWithValue('@TotalCosts')NUMERIC(10,12)is impossible - that would mean a number with 10 digits all together, 12 of which to the right side of the decimal point....