sourav adhikary

sourav adhikary

  • NA
  • 69
  • 21.5k

command parameter

Jun 18 2015 5:26 AM
Hi guys!
I done a project in c#... problem is in command parameter.  my database is in access and all fields datatype is text.
my code is...
 
var dialogResult = MessageBox.Show("Are You want to Submit","Question",MessageBoxButtons.OKCancel,MessageBoxIcon.Question);
if (dialogResult == DialogResult.OK)
{
cmd = new OdbcCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "update brdans set ques='"+Ques_txt.Text+"',ans=@Ans where s_roll='" + Roll + "'";
cmd.Parameters.AddWithValue("@Ans", ans_txt.Text);
cmd.ExecuteNonQuery();
con.Close();
}
 
 
my error comes with message...
 
ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
 
 
thanks in advance 

Answers (2)