I am getting an error while inserting data.
The error is "Number of query values and destination fields are not the same".
I have read alot about ppl missing some single qoutes but I must be overlooking them.
My code :
private void btn_Insert_Click(object sender, EventArgs e)
{
con.Open();
OleDbCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into Table values('" + txt_Date + "','" + txt_Units + "','" + txt_TimeOrd + "','" + txtTimeRec + "','" + txt_Panel + "', '" + txt_Box +"','" + txt_Name + "', '" + txt_Notes +"')";
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Record inserted Successfully");
}
}
}

Ankit SahuRank #1,035 · 1.9K reputationPosted Oct 23, 2017, 8:26 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Oct 21, 2017, 6:11 AM EDT
Saddam Mohd150 reputationPosted Oct 21, 2017, 6:39 AM EDT
Ankit SahuRank #1,035 · 1.9K reputationPosted Oct 21, 2017, 10:12 AM EDT
james jamesRank #4,546 · 338 reputationPosted Oct 22, 2017, 7:27 AM EDT