如果我犯了这个错误,我似乎无法理解。
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
command.CommandText = "INSERT INTO statement workers values(?,?,?,?,?,?,?,?,?)";
command.Parameters.AddWithValue("@Tab", tabtextBox1.Text);
command.Parameters.AddWithValue("@User", usertextBox2.Text);
command.Parameters.AddWithValue("@Pass", passtextBox4.Text);
command.Parameters.AddWithValue("@Names", namestextBox3.Text);
command.Parameters.AddWithValue("@Tele", teletextBox6.Text);
command.Parameters.AddWithValue("@Job", jobtextBox9.Text);
command.Parameters.AddWithValue("@Pay", paytextBox7.Text);
command.Parameters.AddWithValue("@Date", dateofdateTimePicker2.Value.ToShortDateString());
command.Parameters.AddWithValue("@DOB", dobdateTimePicker1.Value.ToShortDateString());
command.ExecuteNonQuery();
MessageBox.Show("Data Saved");在我尝试插入详细信息之后,它给了我一个答复:
oledbexception在insert into语句中出现未处理语法错误
发布于 2016-03-30 12:49:51
另外,您必须使用DateTimePickers的值,而不是字符串:
command.Parameters.AddWithValue("@Date", dateofdateTimePicker2.Value);
command.Parameters.AddWithValue("@DOB", dobdateTimePicker1.Value);并说明字段名:
command.CommandText = "INSERT INTO [statement workers] (fielname1, fieldname2, .., fieldname9) values(?,?,?,?,?,?,?,?,?)";https://stackoverflow.com/questions/36308290
复制相似问题