using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Bookshop
{
class Connection
{
OleDbConnection con;
public OleDbConnection GetConnection()
{
try
{
string str = "Provider = Microsoft.JET.OLEDB.4.0;Data Source = {0}{1}; Jet OLEDB:Database Password =sh004";
str = String.Format(str, System.AppDomain.CurrentDomain.BaseDirectory, "BookSell.mdb");
con = new OleDbConnection();
con.ConnectionString = str;
con.Open();
}
catch (Exception ex)
{
MessageBox.Show("请检查数据库。" + ex.ToString());
}
return con;
}
}
}