我正在尝试从 tblOrderAA 中删除几行,从 tblProInfo 中删除一行:(看图片)
这是代码。我得到的错误是:
“记录已被删除”
private void DeleteFromDataBase()
{
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Projects_2012\\Project_Noam\\Access\\myProject.accdb";
OleDbConnection myConnection = new OleDbConnection(connectionString);
string myDeleteQuery ="DELETE tblOrderAA.*, tblProInfo.*"+
" FROM tblProInfo INNER JOIN tblOrderAA ON tblProInfo.proInfoSerialNum = tblOrderAA.orderAASerialPro" +
" WHERE (((tblProInfo.proInfoScienceName)='"+comboBox1.SelectedItem.ToString()+"'))";
OleDbCommand myCommand = new OleDbCommand(myDeleteQuery);
myCommand.Connection = myConnection;
try
{
myConnection.Open();
myCommand.ExecuteNonQuery();
myCommand.Connection.Close();
MessageBox.Show("success");
}
catch (Exception e)
{
MessageBox.Show("error in : \n" + e.ToString());
}
**注意:**当我使用此代码时,SELECT
它DELETE
可以工作。