日期:2014-05-18 浏览次数:20883 次
using System.Data.OleDb; using System.Data; namespace TestDB { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { String connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\DateBase\db1.mdb;"; OleDbConnection connection = new OleDbConnection(connectionString); connection.Open(); MessageBox.Show("数据库连接成功!"); //connection.Close(); } catch { MessageBox.Show("数据库连接失败!"); } } } }