Hi i want to update my ITEM_DETAILS table in C# using Sql server at the backend but when i am doing this i am getting the following error :
failed to convert parameter value from a string to a decimal. c#
Here is my code:
int x;
da.UpdateCommand = new SqlCommand("UPDATE ITEM_DETAILS SET ITEM_NAME=@ITEM_NAME,ITEM_DESCRIPTION=@ITEM_DESCRIPTION,VENDOR_NAME=@VENDOR_NAME,QUANTITY=@QUANTITY,RATE=@RATE,AMOUNT=@AMOUNT,INVOICE_NUM=@INVOICE_NUM,DATE=@DATE WHERE ITEM_MODEL=@ITEM_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");
}
Can anyone explain me the solution to this problem?