string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/A.mdb";
OleDbConnection odcConnection = new OleDbConnection(strConn); //2、打开连接 C#操作Access之按列读取mdb
odcConnection.Open(); //建立SQL查询
OleDbCommand odCommand = odcConnection.CreateCommand();
odCommand.CommandText = "select * from t1"; //建立读取 C#操作Access之按列读取mdb
OleDbDataReader odrReader = odCommand.ExecuteReader();
ArrayList Arr = new ArrayList();
while (odrReader.Read())
{
Arr.Add(odrReader["NAME"].ToString());
listBox1.Items.Add(odrReader["NAME"].ToString());
}
odrReader.Close();
odcConnection.Close();
C#读DB(access)
最新推荐文章于 2024-09-04 07:00:00 发布