i have created a table for educational information .one of it’s field is for AverageMark and so i have set it’s datatype to Decimal(2,2)-(for example marks such as: 18.21 , 20, 15.50 ,…).
but i don’t know whether is this datatype is correct or sould be changed ?
because when i want to insert into database from Asp.net an exception always thrown which is like below:
cmd.Parameters.Add("@Average", SqlDbType.Decimal).Value = Convert.ToDecimal(Average.Text.Trim());
and the exception is : Error converting data type numeric to decimal.
i don’t konw what to do now to insert marks with only 2 decimal value?
You can try with this code – based on
CultureInfo.InvariantCulture