Hi everyone,
I have an InvalidCastException Error in my program. The program is that i try to insert an employee record into a database table after getting the details from a form. I've used Money data type is SQL Server for salary and SqlTypes.SqlDecimal data type in employee template class. i've used a stored procedure to pass the values and i add the basic value by passing a parameter by the method
Dim prm8 As SqlParameter = com.Parameters.Add("@basic", SqlDbType.Money)
prm8.Direction = ParameterDirection.Input
prm8.Value = emp.Bsc
I've used the money datatype itself even in the stored procedure variable.
I get the following error.
failed to convert parameter value from sql decimal to decimal
Even if i use
prm8.Value = Convert.ToDecimal(emp.Bsc)
I get an error
Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible'.
Please help me with the same. The code contains many files and is too long. As a result i've not pasted it here. Please do let me know if it is needed.
Thanks