You can debug and run your SQL query in SQL management studio to check what is wrong with your query.
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();
var quantity = dgvStockEntry.Rows[i].Cells[5].Value.ToString();
var pcode = dgvStockEntry.Rows[i].Cells[2].Value.ToString();
var sql = $"Update Products set Quantity = '{stockeEntry}' where Pcode like 'pcode'"
cm = new SqlCommand(, cn);
cm.ExecuteNonQuery();
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);
}
* Be the first to Make Comment