Deal with OleDbException : OleDbException « ADO.Net « C# / CSharp Tutorial






using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;


public class MainClass {
  public static void Main(){
        string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\Northwind.mdb";
        OleDbConnection conn = new OleDbConnection(ConnectionString);
        try
        {
            conn.Open();
        }
        catch(OleDbException ae)
        {
            for (int i = 0; i < ae.Errors.Count; i++)
            {
                Console.WriteLine(ae.Errors[i].Message + " - " + ae.Errors[i].SQLState);
            }
        }
  }
}








32.12.OleDbException
32.12.1.Deal with OleDbException