System.Data.OleDb.OleDbException: 'Number of query values and destination fields are not the same.'
Code crashed at statement below. I did check the Access database and all three fields are there.
cmd.CommandText = "insert into Reservation values ('" + @Reservation_Number + "', '" + Property_Name.Text + "', '" + Unit_Number.Text + "')";
Code crashed at statement below. I did check the Access database and all three fields are there.
cmd.CommandText = "insert into Reservation values ('" + @Reservation_Number + "', '" + Property_Name.Text + "', '" + Unit_Number.Text + "')";
Add_Record_Click:
private void Add_Record_Click(object sender, EventArgs e)
{
String Property_ID = "1";
String Month_Var = "12";
String Date_Var = "17";
String Year_Var = "2022";
String Reservation_Number = "R-" + Property_ID + "-" + Unit_Number.Text + "-" + Month_Var + "-"
+ Date_Var + "-" + Year_Var;
MessageBox.Show(Reservation_Number);
con.Open();
OleDbCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into Reservation values ('" + @Reservation_Number + "', '" + Property_Name.Text + "', '" + Unit_Number.Text + "')";
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Record inserted successfully.");
}
Last edited by a moderator: