我遇到了与 MS Access 的 OleDb 连接问题。此行抛出错误:
command1.ExecuteNonQuery();
下一部分是我的代码:
if (textBox.Text.Length != 6) return;
{
cmd.CommandText = ("SELECT last_name +', '+ first_name from name where id =@Name");
cmd.Parameters.Add(new SqlParameter("Name", textBox.Text.Replace(@"L", "")));
cmd.CommandType = CommandType.Text;
cmd.Connection = DBConnection;
returnValue = cmd.ExecuteScalar() + "\t " + textBox.Text.Replace(@"L", "");
DBConnection.Close();
OleDbConnection connection1 = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\Registration.accdb");
OleDbCommand command1 = new OleDbCommand();
command1.CommandText = "UPDATE Table SET ID=@ID, Name=@Name, TimeIn=@TimeInAM, TimeOut=@TimeOutAM";
command1.Parameters.AddWithValue("@ID", returnValue);
connection1.Open();
command1.ExecuteNonQuery();
connection1.Close();
Staff_Register(returnValue, e);
}