using System; using System.Data; using System.Data.OleDb; class Program { static void Main(string[] args) { string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Northwind.mdb;"; string query = "SELECT * FROM Customers"; using (OleDbConnection conn = new OleDbConnection(connString)) { OleDbDataAdapter adapter = new OleDbDataAdapter(query, conn); DataTable table = new DataTable(); adapter.FillSchema(table, SchemaType.Source); foreach (DataColumn column in table.Columns) { Console.WriteLine(column.ColumnName); } } } }
using System; using System.Data; using System.Data.OleDb; class Program { static void Main(string[] args) { string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Northwind.mdb;"; string query = "SELECT * FROM Products"; using (OleDbConnection conn = new OleDbConnection(connString)) { OleDbDataAdapter adapter = new OleDbDataAdapter(query, conn); DataSet ds = new DataSet(); adapter.FillSchema(ds, SchemaType.Source); DataTable table = new DataTable(); ds.Tables.Add(table); adapter.Fill(table); foreach (DataRow row in table.Rows) { Console.WriteLine(row["ProductID"].ToString() + " - " + row["ProductName"].ToString()); } } } }Both examples use the System.Data.OleDb package library.