- using System;
- using System.Data;
- using System.Data.OleDb;
- class TestADO
- {
- static void Main(string[] args)
- {
- string strDSN = Provider=Microsoft.Jet.OLEDB.4.0;DataSource=c:\\test.mdb;
- string strSQL = SELECT * FROM employee ;
- OleDbConnection conn = new OleDbConnection(strDSN);
- OleDbDataAdapter cmd = new OleDbDataAdapter( strSQL, conn );
- conn.Open();
- DataSet ds = new DataSet();
- cmd.Fill( ds, employee );
- DataTable dt = ds.Tables[0];
- foreach( DataRow dr in dt.Rows )
- {
- Console.WriteLine(First name: + dr.ToString() + Last name: + dr.ToString());
- }
- conn.Close();
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/310520133698.html
来源: http://www.codesnippet.cn/detail/310520133698.html