Thrown whenever an error from the SQL Server adapter is encountered.
Object
Exception
SystemException
SQLException
[Visual Basic] Public Class SQLException Inherits SystemException [C#] public class SQLException : SystemException [C++] public __gc class SQLException : public SystemException [JScript] public class SQLException extends SystemException
This class is created whenever the SQL Server adapter encounters a situation that it cannot handle. It always contains at least one instance of SQLError.
Namespace: System.Data.SQL
Assembly: System.Data.dll
The following example displays some of the values of each error collected in a window.
[Visual Basic]
Private Sub ShowAllSQLErrors() Dim myConnection As String Dim mySelect As String Dim dataSet As New DataSet Dim sqlDataSetComm As New SQLDataSetCommand myConnection = "user id=sa;password=;database=northwind;" _ + "server=mySQL;" mySelect = "SELECT * FROM Categories ORDER BY CategoryID" Try Set sqlDataSetComm = SQLDataSetCommand(mySelect, myConnection) sqlDataSetComm.FillDataSet(dataSet) Catch (SQLException SQLExcept) Dim SQLErr As New SQLError For Each SQLErr In SQLExcept.Errors ShowSQLError(SQLErr) Next End Try End Sub Private Sub ShowSQLError(sqlServerErr2 As SQLServerError) Dim myMessage As String Dim myTitle As String Dim myMsgBox As MessageBox myMessage = "Error " + sqlServerErr2.Number _ + " on Server " + sqlServerErr2.Server + ": " _ + sqlServerErr2.Message + " on Line " _ + sqlServerErr2.LineNumber myTitle = "SQL Server Error" myMsgBox.Show myMessage, myTitle End Sub
SQLException Members | System.Data.SQL Namespace | SQLError | SQLErrors