I got this error below while trying to update product table:
Unclosed quotation mark after the character string " where ProID=''. Incorrect syntax near "where ProID =''.
My codes:
- private void btnUpdate_Click(object sender, EventArgs e)
- {
- try
- {
- con.Open();
- cmd = new SqlCommand("UPDATE tbl_Products SET ProName='" +txtProName.Text+"' where ProID='"+txtProID.Text+"' ", con);
- cmd.ExecuteNonQuery();
- con.Close();
- MessageBox.Show("Product Info Saved...");
- fillGrid();
- cleartext();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- con.Close();
- {
- }
- }
- private void cleartext()
- {
- txtProID.Text = "";
- txtProName.Text = "'";
- }
- }
- }
Please help me find the unclosed quotation
thanks