I got error "No value given for one or more required parameters" error when executing the following code. I checked the value of the query and it seems correct. Does anyone know why?
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Catherine\\Documents\\LearningCSharp.accdb"; OleDbConnection myConnection = new OleDbConnection(connectionString); myConnection.Open(); int employeeNumber = int.Parse(textBox1.Text); string name = textBox2.Text; string address = textBox3.Text; string query = "update EMPLOYEE set EmployeeName='"+ name + "', Address='"+ address + "' where EmployeeID = "+ employeeNumber; OleDbCommand myCommand = new OleDbCommand(); myCommand.CommandText = query; myCommand.Connection = myConnection; myCommand.ExecuteNonQuery(); myConnection.Close();
Thanks in advance.