alexa

Error during SQL Update: "Incorrect Syntax Near '1'" [closed] in sql ?

Error during SQL Update: "Incorrect Syntax Near '1'" [closed] in sql ?

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);
        } 

393 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online

Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry