using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data.SqlClient;
namespace CSharpAccess
{
class Program
{
static void Main(string[] args)
{
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/school.mdb");
conn.Open();
string sql = "select * from student";
OleDbCommand command = new OleDbCommand(sql, conn);
OleDbDataReader reader = command.ExecuteReader();
try
{
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount;i++ )
{
Console.Write("{0} ", reader[i]);
}
Console.WriteLine();
}
}
finally
{
reader.Close();
conn.Close();
}
}
}
}
摘自 I_code