OleDbException Class
Assembly: System.Data (in system.data.dll)
'Declaration <SerializableAttribute> _ Public NotInheritable Class OleDbException Inherits DbException 'Usage Dim instance As OleDbException
/** @attribute SerializableAttribute() */ public final class OleDbException extends DbException
SerializableAttribute public final class OleDbException extends DbException
This class is created whenever the .NET Framework Data Provider for OLE DB encounters an error generated from the server. (Client side errors are thrown as standard common language runtime exceptions.) OleDbException always contains at least one instance of OleDbError.
If the severity of the error is too great, the server may close the OleDbConnection. However, the user can reopen the connection and continue.
The following example generates an OleDbException because of a missing data source, and then displays the exception.
Public Sub ShowOleDbException() Dim mySelectQuery As String = "SELECT column1 FROM table1" Dim myConnection As New OleDbConnection _ ("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=") Dim myCommand As New OleDbCommand(mySelectQuery, myConnection) Try myCommand.Connection.Open() Catch e As OleDbException Dim errorMessages As String Dim i As Integer For i = 0 To e.Errors.Count - 1 errorMessages += "Index #" & i.ToString() & ControlChars.Cr _ & "Message: " & e.Errors(i).Message & ControlChars.Cr _ & "NativeError: " & e.Errors(i).NativeError & ControlChars.Cr _ & "Source: " & e.Errors(i).Source & ControlChars.Cr _ & "SQLState: " & e.Errors(i).SQLState & ControlChars.Cr Next i Dim log As System.Diagnostics.EventLog = New System.Diagnostics.EventLog() log.Source = "My Application" log.WriteEntry(errorMessages) Console.WriteLine("An exception occurred. Please contact your system administrator.") End Try End Sub
System.Exception
System.SystemException
System.Runtime.InteropServices.ExternalException
System.Data.Common.DbException
System.Data.OleDb.OleDbException
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.