Deal with OleDbException : OleDbException : ADO.Net C# Examples


C# Examples » ADO.Net » OleDbException »

 

Deal with OleDbException









    
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);
                        }
                }
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo ADO.Net
» OleDbException