private void CallAccess()
{
string OLEDBConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};";
string resourcePath = filePath("100keypolluters.mdb");
OLEDBConnStr = string .Format(OLEDBConnStr,resourcePath);
string strCreateTableSQL = "select count(*) from enterprises_05";
OleDbConnection oConn = new OleDbConnection();
oConn.ConnectionString = OLEDBConnStr;
OleDbCommand oCreateComm = new OleDbCommand();
oCreateComm.Connection = oConn;
oCreateComm.CommandText = strCreateTableSQL;
oConn.Open();
object count = oCreateComm.ExecuteScalar();
oConn.Close();
}
private string filePath(string fileName)
{
string resourcePath = Application.StartupPath;
resourcePath = resourcePath.Replace(@"bin\Debug",@"resource\");
resourcePath += fileName;
return resourcePath;
}

浙公网安备 33010602011771号