please trace an error in the following code?
please help,, this particular code has become headache for me!!! i coudnt get it " where m i wrong???please trace an error in the following code. this is simple code to update data,, i dont know y it is giving "Syntax error in UPDATE statement."
OleDbConnection con = new OleDbConnection();
con.ConnectionString = connection.connstring;
con.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText ="update info set city=@a,cname=@b,contactno=@c,add=@d,pincode=@e where fname='" + comboBox1.Text + "'";
cmd.Connection = con;
cmd.Parameters.AddWithValue("@a", comboBox2.Text);
cmd.Parameters.AddWithValue("@b", textBox1.Text);
cmd.Parameters.AddWithValue("@c", textBox2.Text);
cmd.Parameters.AddWithValue("@d", richTextBox1.Text);
cmd.Parameters.AddWithValue("@e", textBox3.Text);
int i = cmd.ExecuteNonQuery();
if (i > 0)
{
MessageBox.Show("data is updated");
}
thanks in advance!!
Jaspreet KaurPosted Jun 21, 2012, 9:43 PM
but even i have used UPDATE query like this!!
but still "error in update statement" comes!!!
i dont know what i have done wrong...
i couldnt trace this problem..
rakesh chaudhariPosted Jun 21, 2012, 7:08 AM
com = new SqlCommand(str, Connection.GetConnection()); // Connectionstring
com.ExecuteNonQuery();
Please Check this if Not usefull then properly add u r problem