Rao Varrey

Rao Varrey

  • NA
  • 56
  • 3.1k

Error when trying to save updated fields to Access database

Oct 1 2017 11:04 PM
private void button1_Click(object sender, EventArgs e)
{
// Saves changes made in the details
OdbcConnection myConnection = new OdbcConnection();
OdbcCommand cmd = myConnection.CreateCommand();
string myConnectionString = @"Driver={Microsoft Access Driver (*.mdb)};" + "Dbq=C:/DROPS-Data/Derrick.mdb";
{
myConnection.ConnectionString = myConnectionString;
//execute queries, etc
cmd.CommandText = "UPDATE InspInfo SET CompanyName = @cName, CustomerRef = @cRef Where WONo = @WO";
cmd.Parameters.AddWithValue("@cName",textBox1.Text);
cmd.Parameters.AddWithValue("@cRef", textBox2.Text);
cmd.Parameters.AddWithValue("@WO", textBox6.Text);
myConnection.Open();
cmd.ExecuteNonQuery();
myConnection.Close();
}
}
 

Error message

System.Data.Odbc.OdbcException (0x80131937): ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 3.
 
Can somebody help please 
 
 
 
 

Answers (6)