查了许多网页,终于找到了
string namemdb="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Application.StartupPath+"\\3d.mdb"+";Jet OLEDB:Engine Type=5";//连接字符串
OleDbConnection con =new OleDbConnection(namemdb);//连接数据库
con.Open(); //打开数据库
OleDbCommand oledbcom = new OleDbCommand("SELECT COUNT(*) FROM 3d", con);//定义SQL命令,计算记录数量
int count = (int)oledbcom.ExecuteScalar();//执行并返回