OdbcConnection for Access mdb file : OdbcConnection « ADO.Net « C# / CSharp Tutorial






using System;
using Microsoft.Data.Odbc;

class MainClass
{
    static void Main(string[] args)
    {
        string connectionString  = @"Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\Northwind.mdb";
        string SQL = "SELECT * FROM Orders";

        OdbcConnection  conn = new OdbcConnection(connectionString);
    
        OdbcCommand cmd = new OdbcCommand(SQL);
        cmd.Connection = conn;

        conn.Open();

        OdbcDataReader reader = cmd.ExecuteReader();

        while (reader.Read()) 
        {
            Console.Write("OrderID:"+reader.GetInt32(0).ToString() );
            Console.Write(" ,");
            Console.WriteLine("Customer:" + reader.GetString(1).ToString() );
        }

        reader.Close();
        conn.Close();
    }
}








32.49.OdbcConnection
32.49.1.OdbcConnection for Access mdb file
32.49.2.Use ODBC Data Provider