I Have a Datalist that is populated by a table and when I try to update the table from the Datalist I get the Exception: “Failed to convert parameter value from a String to a Double”
here is the click of the update button:
for (int x = 0; x < dlQtyBreak.Items.Count; x++)
{
DataListItem item = dlQtyBreak.Items[x];
string linenum = ((Label)item.FindControl("lblPBLinenum")).Text;
string lowqty = ((TextBox)item.FindControl("txtPBLowQty")).Text;
string highqty = ((TextBox)item.FindControl("txtPBHighQty")).Text;
string price = ((TextBox)item.FindControl("txtPBPrice")).Text;
string salesprice = ((TextBox)item.FindControl("txtPBSalesPrice")).Text;
DAL.Util.updatePriceBreakRow(IQPDID(), lowqty, highqty, price, salesprice, linenum);
}
and this next code is the sql and the parameters
public static void updatePriceBreakRow(string IQPDID, string low, string high, string price, string sPrice, string linenum)
{
string sql = "UPDATE ItemQtyPriceDiscTable SET LowQuantity=@LowQty, HighQuantity=@HighQty, Price=@Price WHERE linenum=@lineNum";
AdoUtil.ACESSQLParameterCollection parameters = new AdoUtil.ACESSQLParameterCollection();
AdoUtil.ACESSQLParameter param = new AdoUtil.ACESSQLParameter();
param.ParamName = "@IQPDID";
param.ParamValue = IQPDID;
param.ParamDBType = SqlDbType.Int;
parameters.Add(param);
param.ParamName = "@LowQty";
param.ParamValue = low;
param.ParamDBType = SqlDbType.Float;
parameters.Add(param);
param.ParamName = "@HighQty";
param.ParamValue = high;
param.ParamDBType = SqlDbType.Float;
parameters.Add(param);
param.ParamName = "@Price";
param.ParamValue = price;
param.ParamDBType = SqlDbType.Float;
parameters.Add(param);
param.ParamName = "@SalePrice";
param.ParamValue = sPrice;
param.ParamDBType = SqlDbType.Float;
parameters.Add(param);
param.ParamName = "@linenum";
param.ParamValue = linenum;
param.ParamDBType = SqlDbType.Int;
parameters.Add(param);
param.ParamName = "@update";
param.ParamValue = lastUpdate;
param.ParamDBType = SqlDbType.VarChar;
parameters.Add(param);
AdoUtil.ExecuteNonQuery(sql, parameters);
}
What can be causing this? When I do the same process on another datalist it works, only difference is that table uses all Int and varchar values where this one uses Float and varchar. If anyone has any helpful insight to help solve this problem it will be greatly appreciated. And if there is any other code that could be useful just ask and I can post it.
Thank you.
Since you say all your tests have been with out a value populated for “SalesPrice” try removing or commenting out
and then run it as you have been and see if that results in the same or not. It could be holding up on that empty string.
and if it does turn out to be whats causing it just add a check in there and then exclude that parameter