Csharp/CSharp Tutorial/ADO.Net/OleDbException
Deal with OleDbException
<source lang="csharp">using System; using System.Drawing; using System.Collections; using System.ruponentModel; 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); } } }
}</source>