C
Chris Ashley
I am running a stored procedure and getting the error 'Error converting
data type numeric to decimal'. I just can't work out why. My stored
procedure values are defined like so:
@addOn1 decimal(7,2),
@addOn2 decimal(7,2),
@addOn3 decimal(7,2),
@addOn4 decimal(7,2),
@addOn5 decimal(7,2),
@addOn6 decimal(7,2),
@addOn7 decimal(7,2),
@addOn8 decimal(7,2)
These map to the precision/scale values in my database.
I am calling the stored procedure from dotnet like so:
sqlCmd.Parameters.Add("addOn1", objPremium.addOn1);
sqlCmd.Parameters.Add("addOn2", objPremium.addOn2);
sqlCmd.Parameters.Add("addOn3", objPremium.addOn3);
sqlCmd.Parameters.Add("addOn4", objPremium.addOn4);
sqlCmd.Parameters.Add("addOn5", objPremium.addOn5);
sqlCmd.Parameters.Add("addOn6", objPremium.addOn6);
sqlCmd.Parameters.Add("addOn7", objPremium.addOn7);
sqlCmd.Parameters.Add("addOn8", objPremium.addOn8);
try
{
sqlCmd.ExecuteNonQuery();
blnReturnVal = true;
}
catch(Exception e)
{
Debug.Trace.WriteLine(e);
blnReturnVal = false;
}
And getting the exception there.
the objPremium.addOn1 - objPremium.addOn8 values are all decimals. I am
instantiating them like so and not setting them to anything else (for
debug purposes):
public decimal addOn1 = -1;
public decimal addOn2 = -1;
public decimal addOn3 = -1;
public decimal addOn4 = -1;
public decimal addOn5 = -1;
public decimal addOn6 = -1;
public decimal addOn7 = -1;
public decimal addOn8 = -1;
I'm sure it's something obvious, but can anybody spot what I'm doing
wrong?
Thanks in advance!
data type numeric to decimal'. I just can't work out why. My stored
procedure values are defined like so:
@addOn1 decimal(7,2),
@addOn2 decimal(7,2),
@addOn3 decimal(7,2),
@addOn4 decimal(7,2),
@addOn5 decimal(7,2),
@addOn6 decimal(7,2),
@addOn7 decimal(7,2),
@addOn8 decimal(7,2)
These map to the precision/scale values in my database.
I am calling the stored procedure from dotnet like so:
sqlCmd.Parameters.Add("addOn1", objPremium.addOn1);
sqlCmd.Parameters.Add("addOn2", objPremium.addOn2);
sqlCmd.Parameters.Add("addOn3", objPremium.addOn3);
sqlCmd.Parameters.Add("addOn4", objPremium.addOn4);
sqlCmd.Parameters.Add("addOn5", objPremium.addOn5);
sqlCmd.Parameters.Add("addOn6", objPremium.addOn6);
sqlCmd.Parameters.Add("addOn7", objPremium.addOn7);
sqlCmd.Parameters.Add("addOn8", objPremium.addOn8);
try
{
sqlCmd.ExecuteNonQuery();
blnReturnVal = true;
}
catch(Exception e)
{
Debug.Trace.WriteLine(e);
blnReturnVal = false;
}
And getting the exception there.
the objPremium.addOn1 - objPremium.addOn8 values are all decimals. I am
instantiating them like so and not setting them to anything else (for
debug purposes):
public decimal addOn1 = -1;
public decimal addOn2 = -1;
public decimal addOn3 = -1;
public decimal addOn4 = -1;
public decimal addOn5 = -1;
public decimal addOn6 = -1;
public decimal addOn7 = -1;
public decimal addOn8 = -1;
I'm sure it's something obvious, but can anybody spot what I'm doing
wrong?
Thanks in advance!