c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -
I'm new to this I'm writing a clr. stored procedure that can be used to get values used in a calculation Call for another stored procedure for
Gives an archived methodology int (I think SqlInt32? Value of the table's value is int) which is then necessary to convert to decimal.
Here I have the code:
Public static integral mood (SQL MDMMYLUE, escalistering AMY type, out of SQLDCM Result) {aResult = 0; Try {SqlConnection conn = New SqlConnection ("Reference Connection = True"); SqlCommand cmd = New SqlCommand ("sp_GetType", conn); Cmd.Parameters.AddWithValue ("@ myValueType", aMyValueType); Cmd.CommandType = CommandType.StoredProcedure; Conn.Open (); Object type = CMD. Exclamation Asser (); Conn.Close (); Decimal type FORCalculation = Convert. ToDecimal (type); Decimal value = convert toDecimal (aMyValue); // ** calculation calc = new calculation (); Decimal result = calorie.docalulation (typefarculation, value);
I get an exception (I think that there ******):
Unable to remove type object 'System Datas.SqlTypes .qlDecimal 'to' System.IConvertible 'to type.
Any ideas? Thank you.
The problem is that the SQL type does not apply to IConvertible
interface, Which uses convert
you need to enter type
in SqlDecimal
, then to get the value
Use the decimal
presentation:
decimal type FORCalculation = ((SqlDecimal) type). value; Decimal value = aMyValue.Value;
Comments
Post a Comment