我正在使用以下代码来获取号码。MS Access Db 中的填充行数。但是我在打开命令时收到以下错误
public static int CountRecordsInAccess(string ResultFile)//TODO
{
string ResultFilePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + ResultFile;
string ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0" + ";Data Source=" + ResultFilePath + ";Extended Properties=Excel 12.0;Persist Security Info=False";
//Create Connection
OleDbConnection AccessConnection = new OleDbConnection(ConnectionString);
AccessConnection.Open();
//Create OleDbCommand to fetch data
OleDbCommand cmd = new OleDbCommand("SELECT COUNT (*) FROM Table1" , AccessConnection);
int rows = (int)cmd.ExecuteScalar();
AccessConnection.Close();
return rows;
}
请建议我哪里出错了