I have an application that I'm trying to use to make some database updates. However, whenever I try to save, I get this error message:
Incorrect Syntax Near '1'
What does this error message mean, and how can I solve it? Here's my code:
try
{
if (dgvStockEntry.Rows.Count > 0)
{
if (MessageBox.Show("Are you sure you want to save this records?", stitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
for (int i = 0; i < dgvStockEntry.Rows.Count; i++)
{
cn.Open();
cm = new SqlCommand("Update Products set Quantity = Quantity '" + dgvStockEntry.Rows[i].Cells[5].Value.ToString() + "' where Pcode like '" + dgvStockEntry.Rows[i].Cells[2].Value.ToString() + "'", cn);
cm.ExecuteNonQuery();
cn.Close();
cn.Open();
cm = new SqlCommand("Update StockEntry set Quantity = Quantity '" + dgvStockEntry.Rows[i].Cells[5].Value.ToString() + ", Status = 'Done' where Id like '" + dgvStockEntry.Rows[i].Cells[0].Value.ToString() + "'", cn);
cm.ExecuteNonQuery();
cn.Close();
}
Clear();
LoadStockEntry();
}
}
}
catch (Exception ex)
{
cn.Close();
MessageBox.Show(ex.Message, stitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}