附件:http://files.cnblogs.com/xe2011/AccesssConnectionState.rar
using System.Data.OleDb; using System.Data.Common; //连接 private void button1_Click(object sender, EventArgs e) { string FileName = "MangerDataBase.mdb"; string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" +FileName; OleDbConnection con = new OleDbConnection(ConStr); con.Open(); if (con.State == ConnectionState.Open) { MessageBox.Show("Access数据库的连接成功!"); } else { MessageBox.Show("Access数据库的连接失败!"); } con.Close(); }