该声明:
SELECT [ToWhom] FROM [myChecks] WHERE [ToWhom] like '*e*'
在 Access 中工作正常,但是当我从 C# 运行它时,我会返回并清空数据集。这是代码:
string connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Checkbook.accdb";
OleDbConnection Conn = new OleDbConnection();
Conn.ConnectionString = connectionstring;
OleDbCommand myCommand = Conn.CreateCommand();
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter();
DataSet myDataset = new DataSet();
DataTable EmptyDataTable = new DataTable();
myCommand.CommandText = SQL;
myDataAdapter.SelectCommand = myCommand;
Conn.Open();
try
{
//This part does not throw an error it just return an empty Dataset
myDataAdapter.Fill(myDataset);
Conn.Close();
return myDataset.Tables[0];
}
catch(SyntaxErrorException e)
{
MessageBox.Show(e.Message, "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Conn.Close();
return EmptyDataTable;
}
任何帮助,将不胜感激。