Bagikan melalui


SqlError.LineNumber Properti

Definisi

Mendapatkan nomor baris dalam batch perintah Transact-SQL atau prosedur tersimpan yang berisi kesalahan.

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

Nilai Properti

Nomor baris dalam batch perintah Transact-SQL atau prosedur tersimpan yang berisi kesalahan.

Contoh

Contoh berikut menampilkan masing-masing SqlError dalam SqlErrorCollection koleksi.

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

Keterangan

Penomoran baris dimulai dari 1. Jika nilainya adalah 0, nomor baris tidak berlaku.

Untuk informasi selengkapnya tentang kesalahan yang dihasilkan oleh SQL Server, lihat Peristiwa dan Kesalahan Mesin Database.

Berlaku untuk

Lihat juga