Advertisement
Sparrowvivek16

MySQL Error

Nov 24th, 2015
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order (service,price,billno,dates) VALUES ('WASH (L)','13','BILL-00002','2015-11' at line 1
  2.  
  3.  
  4. string a,b;
  5.                foreach (DataGridViewRow row in dataGridView1.Rows)
  6.                {
  7.  
  8.                    a = dataGridView1.Rows[row.Index].Cells["Service"].Value + "";
  9.                    b = dataGridView1.Rows[row.Index].Cells["Price"].Value + "";
  10.  
  11.                    string query1 = "INSERT INTO order (service,price,billno,dates) VALUES (@1,@2,@3,@4)";
  12.                    MySqlCommand cmd1 = new MySqlCommand(query1, con);
  13.                    cmd1.Parameters.AddWithValue("@1", a);
  14.                    cmd1.Parameters.AddWithValue("@2", b);
  15.                    cmd1.Parameters.AddWithValue("@3", label15.Text);
  16.                    cmd1.Parameters.AddWithValue("@4", label17.Text);
  17.                    cmd1.ExecuteNonQuery();
  18.                    
  19.                }
  20.                con.Close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement