im using asp.net, C# to enter data into a table in sql
server...however im getting this error:
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a
correct format.
Source Error:
Line 120:cmd.Parameters.Add("@commission",SqlDbType.Mon ey);
Line 121:cmd.Parameters["@commission"].Direction=ParameterDirection.Input;
Line 122:cmd.Parameters["@commission"].Value =
Convert.ToDouble(txtinvoice.Text);
Line 123:cmd.Parameters.Add("@pricesold",SqlDbType.Mone y);
Line 124:cmd.Parameters["@pricesold"].Direction=ParameterDirection
Similar error messages appear when I leave text fields blank that are
going to be inserted into fields in the table of datatype money,
datetime or int...
however when i execute this in query analyzer it works and inputs null
values for those fields:
declare @empid varchar(20), @inventoryid int, @clientid int,
@commission money,@pricesold money, @datesold datetime, @invoiceid
int, @shippingcost money, @terms varchar(50), @details varchar(50),
@clienttype smallint, @checker int, @errordesc varchar(100)
set @empid = 'admin'
set @inventoryid = 14
set @clientid= 2
set @clienttype = 0
set @commission = null
exec STP_updateconsignment @empid, @inventoryid, @clientid,
@commission,@pricesold, @datesold, @invoiceid, @shippingcost, @terms,
@details, @clienttype, @checker output, @errordesc output
If Im in enterprise manager and try to enter a blank value into one of
those fields I get: The value you entered is not consistent with the
data type or length of the column...so im wondering if the C# page is
sending my stored procedure a blank value instead of a Null and
causing this error?
any advice would be nice..thanks
-Jim