foreach (GridViewRow g1 in GridView1.Rows)
{
SqlCommand cmd = new SqlCommand("INSERT INTO Order VALUES(@buyersName, @deliveryAddress, @productID, @productName, @category, CONVERT(VARBINARY(MAX), @image), @price, @paymentMode, @holderName)", con);
cmd.Parameters.AddWithValue("@buyersName", Label2.Text);
cmd.Parameters.AddWithValue("@deliveryAddress", TextBox1.Text);
cmd.Parameters.AddWithValue("@productID", g1.Cells[0].Text);
cmd.Parameters.AddWithValue("@productName", g1.Cells[1].Text);
cmd.Parameters.AddWithValue("@category", g1.Cells[2].Text);
cmd.Parameters.AddWithValue("@image", g1.Cells[3].Text);
cmd.Parameters.AddWithValue("@price", g1.Cells[4].Text);
cmd.Parameters.AddWithValue("@paymentMode", checkRadioButton());
cmd.Parameters.AddWithValue("@holderName", TextBox2.Text);
int r = cmd.ExecuteNonQuery();
}
When I run this code, it is showing an error that there is a syntax error near "Order". checkRadioButton()
is returning the label of the selected RadioButton
.