Reading Access Data : Access : Database C# Source Code


Custom Search

C# Source Code » Database » Access »

 

Reading Access Data








    
 
using System;
using System.Data;           
using System.Data.OleDb;     
using System.Collections.Generic;
using System.Text;

class Program {
    static void Main(string[] args) {
        OleDbConnection thisConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\nwind.mdb");
        thisConnection.Open();
        OleDbCommand thisCommand = thisConnection.CreateCommand();
        thisCommand.CommandText = "SELECT CustomerID, CompanyName FROM Customers";
        OleDbDataReader thisReader = thisCommand.ExecuteReader();
        while (thisReader.Read()) {
            Console.WriteLine("\t{0}\t{1}",thisReader["CustomerID"], thisReader["CompanyName"]);
        }
        thisReader.Close();
        thisConnection.Close();
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Database
» Access