I get
System.Data.OleDb.OleDbException (0x80040E10): Can not value for one or more of the required parameters
error while using the code below. the variable ‘orderAASerialAA’ is set as autoNumber.
‘this.row’ is string which converted to int32.
private void updateRow_Click(object sender, EventArgs e)
{
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Projects_2012\\Project_Noam\\Access\\myProject.accdb";
OleDbConnection myConnection = new OleDbConnection(connectionString);
string myInsertQuery = (String.Format("UPDATE tblOrderAA SET orderAASreialPro='{0}', orderAAcodon1='{1}' " +
" WHERE orderAASerialAA='{2}'", serialPro.Text, codon1.Text, this.row));
OleDbCommand myCommand = new OleDbCommand(myInsertQuery);
myCommand.Connection = myConnection;
myConnection.Open();
myCommand.ExecuteNonQuery();
myCommand.Connection.Close();
}
That error message usually signals an incorrectly typed column name.
Also I would suggest that you don’t create the queries in this way because of sql injection attacks etc. Use parameterized queries instead.