【C#学习笔记】读access2007
using System; using System.Data.OleDb; namespace ConsoleApplication { class Program { static void Main(string[] args) { string strConnection = "Provider = Microsoft.ACE.OLEDB.12.0;"; strConnection += @"Data Source = c:/Database1.accdb "; OleDbConnection con = new OleDbConnection(strConnection); con.Open(); OleDbCommand com = con.CreateCommand(); com.CommandText = "SELECT * FROM 表1"; OleDbDataReader reader = com.ExecuteReader(); while (reader.Read()) { Console.WriteLine((string)reader["姓名"]+" "+(int)reader["年龄"]+" "+(string)reader["性别"]); } reader.Close(); con.Close(); Console.Read(); } } }