string strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;";
strConnection += @"Data Source=D:\database\material.accdb";
//建立数据库连接
OleDbConnection conn = new OleDbConnection(strConnection);
//打开连接
conn.Open();
string Access = "select * from CUSTMATERIAL1";
OleDbCommand cmd = new OleDbCommand(Access, conn);
OleDbDataAdapter adapter = new OleDbDataAdapter(Access, conn);
//建立数据集
DataSet myds = new DataSet();
adapter.Fill(myds,"CUSTMATERIAL1");
dataGridView1.DataSource = myds.Tables[0];