I am trying to insert some data into the database but getting the error mentioned above. The data type for this field in SQL Server is numeric(4,2). I have tried all kind of solution but cannot get it to work. here is my code:
TextBox Hours = row.FindControl("Hrs") as TextBox;
cmd.CommandText = "insert into myTable (ID, HOURS) values (@ID, @HOURS) ";
cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = ID.Text;
cmd.Parameters.Add("@HOURS", SqlDbType.VarChar).Value = Convert.ToInt32(Hours.ToString());
i have also tried to use decimal but not sure how to fix it. thanks
ToString()on aTextBoxwill not give you a useful string