日期:2014-05-18  浏览次数:20793 次

Access数据库的连接
做的一个小东西 怎么连接Access数据库呢 代码 sql server 的好连  
  大神们 教教

------解决方案--------------------
using System.Data;
using System.Data.OleDb;


OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\123.mdb");
------解决方案--------------------
string connStr, selectCmd;

connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=POST.mdb";
selectCmd = "Select * From Customer Order By ID ASC";
OleDbConnection conn;
OleDbDataAdapter myAdapter;
DataSet myDataSet = new DataSet();
conn = new OleDbConnection(connStr);
myAdapter = new OleDbDataAdapter(selectCmd, conn);
myAdapter.Fill(myDataSet, "Customer");

dataGrid1.DataSource = myDataSet.Tables["Customer"];