SqlError.Number Tulajdonság

Definíció

Lekéri a hiba típusát azonosító számot.

public:
 property int Number { int get(); };
public int Number { get; }
member this.Number : int
Public ReadOnly Property Number As Integer

Tulajdonság értéke

A hiba típusát azonosító szám.

Példák

Az alábbi példa mindegyik SqlError a gyűjteményen SqlErrorCollection belül jelenik meg.

public void DisplaySqlErrors(SqlException exception)
{
    for (int i = 0; i < exception.Errors.Count; i++)
    {
        Console.WriteLine("Index #" + i + "\n" +
            "Source: " + exception.Errors[i].Source + "\n" +
            "Number: " + exception.Errors[i].Number.ToString() + "\n" +
            "State: " + exception.Errors[i].State.ToString() + "\n" +
            "Class: " + exception.Errors[i].Class.ToString() + "\n" +
            "Server: " + exception.Errors[i].Server + "\n" +
            "Message: " + exception.Errors[i].Message + "\n" +
            "Procedure: " + exception.Errors[i].Procedure + "\n" +
            "LineNumber: " + exception.Errors[i].LineNumber.ToString());
    }
    Console.ReadLine();
}
Public Sub DisplaySqlErrors(ByVal exception As SqlException)
    Dim i As Integer

    For i = 0 To exception.Errors.Count - 1
        Console.WriteLine(("Index #" & i & ControlChars.NewLine & _
            "Source: " & exception.Errors(i).Source & ControlChars.NewLine & _
            "Number: " & exception.Errors(i).Number.ToString() & ControlChars.NewLine & _
            "State: " & exception.Errors(i).State.ToString() & ControlChars.NewLine & _
            "Class: " & exception.Errors(i).Class.ToString() & ControlChars.NewLine & _
            "Server: " & exception.Errors(i).Server & ControlChars.NewLine & _
            "Message: " & exception.Errors(i).Message & ControlChars.NewLine & _
            "Procedure: " & exception.Errors(i).Procedure & ControlChars.NewLine & _
            "LineNumber: " & exception.Errors(i).LineNumber.ToString()))
    Next i
    Console.ReadLine()
End Sub

Megjegyzések

Az alábbi táblázat a tulajdonság lehetséges értékeit ismerteti:

A hiba forrása SqlError.Number SqlError.State Az SqlException belső Win32Exception (a.NET Framework 4.5-ös verziótól kezdve)
Hiba a kiszolgálóról Kiszolgálói hibakód

Ez a szám a tábla egyik bejegyzésének master.dbo.sysmessages felel meg.
Általában 0-nál nagyobb No
Kapcsolati időkorlát -2 0 Igen (Szám = 258)
Kommunikációs hiba (nem LocalDB) Win32 hibakód 0 Igen (Szám = Win32 hibakód)
Kommunikációs hiba (LocalDB) Win32 hibakód 0 No
A titkosítási képesség eltérése 20 0 No
Nem sikerült elindítani a LocalDB-t Win32 hibakód 0 No
Írásvédett útválasztási hiba 0 0 No
A kiszolgáló súlyos hibafeldolgozási lekérdezést kapott 0 0 No
Feldolgozott lemondás az eredmények elemzése során 0 0 No
Nem sikerült létrehozni a felhasználói példányt 0 0 No

A SQL Server által generált hibákról további információt a Database Engine Események és hibák című témakörben talál.

A következőre érvényes:

Lásd még