0
嗨,我想使用SQL Server在后端更新我ITEM_DETAILS在C#中的表,但是当我这样做我收到以下错误:无法将参数值从字符串转换为小数。 C#?
failed to convert parameter value from a string to a decimal. c#
这里是我的代码:
int x;
da.UpdateCommand = new SqlCommand("UPDATE ITEM_DETAILS SET [email protected]_NAME,[email protected]_DESCRIPTION,[email protected]_NAME,[email protected],[email protected],[email protected],[email protected]_NUM,[email protected] WHERE [email protected]_MODEL", con);
da.UpdateCommand.Parameters.Add("@ITEM_NAME", SqlDbType.VarChar).Value = txtItemName.Text;
da.UpdateCommand.Parameters.Add("@ITEM_DESCRIPTION", SqlDbType.VarChar).Value = txtItemDescription.Text;
da.UpdateCommand.Parameters.Add("@VENDOR_NAME", SqlDbType.VarChar).Value = txtVendor.Text;
da.UpdateCommand.Parameters.Add("@QUANTITY", SqlDbType.Int).Value = txtQuantity.Text;
da.UpdateCommand.Parameters.Add("@RATE", SqlDbType.Money).Value = txtRate.Text;
da.UpdateCommand.Parameters.Add("@AMOUNT", SqlDbType.Money).Value = txtAmount.Text;
da.UpdateCommand.Parameters.Add("@INVOICE_NUM", SqlDbType.Int).Value = txtInvoice.Text;
da.UpdateCommand.Parameters.Add("@DATE", SqlDbType.VarChar).Value = dateTimePicker1.Value;
da.UpdateCommand.Parameters.Add("@ITEM_MODEL", SqlDbType.VarChar).Value = ds.Tables[0].Rows[bs.Position][0];
con.Open();
x = da.UpdateCommand.ExecuteNonQuery();
con.Close();
if (x >= 1)
{
MessageBox.Show("Record(s) has been updated");
}
任何人都可以解释我解决这个问题吗?
哪个字段是十进制的? txtAmount?如果是,请检查您的分隔符是“1.23”而不是“1,23”的“点”。检查空格或其他字符 – Portekoi
可能的重复[无法将参数值从字符串转换为十进制?](http://stackoverflow.com/questions/12982208/failed-to-convert-parameter-value-from-a -string到一个十进制) – dcastro