SqlErrorCollection 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
.NET Framework Data Provider for SQL Server에서 생성된 모든 오류를 수집합니다. 이 클래스는 상속할 수 없습니다.
public ref class SqlErrorCollection sealed : System::Collections::ICollection
[System.ComponentModel.ListBindable(false)]
[System.Serializable]
public sealed class SqlErrorCollection : System.Collections.ICollection
[<System.ComponentModel.ListBindable(false)>]
[<System.Serializable>]
type SqlErrorCollection = class
interface ICollection
interface IEnumerable
Public NotInheritable Class SqlErrorCollection
Implements ICollection
- 상속
-
SqlErrorCollection
- 특성
- 구현
예제
다음 예제에서는 컬렉션 내에서 각각 SqlError 을 표시합니다 SqlErrorCollection .
public static void ShowSqlException(string connectionString)
{
string queryString = "EXECUTE NonExistantStoredProcedure";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(queryString, connection);
try
{
command.Connection.Open();
command.ExecuteNonQuery();
}
catch (SqlException ex)
{
DisplaySqlErrors(ex);
}
}
}
private static void DisplaySqlErrors(SqlException exception)
{
for (int i = 0; i < exception.Errors.Count; i++)
{
Console.WriteLine("Index #" + i + "\n" +
"Error: " + exception.Errors[i].ToString() + "\n");
}
Console.ReadLine();
}
Public Sub ShowSqlException(ByVal connectionString As String)
Dim queryString As String = "EXECUTE NonExistantStoredProcedure"
Using connection As New SqlConnection(connectionString)
Dim command As New SqlCommand(queryString, connection)
Try
command.Connection.Open()
command.ExecuteNonQuery()
Catch ex As SqlException
DisplaySqlErrors(ex)
End Try
End Using
End Sub
Private Sub DisplaySqlErrors(ByVal exception As SqlException)
Dim i As Integer
For i = 0 To exception.Errors.Count - 1
Console.WriteLine("Index #" & i & ControlChars.NewLine & _
"Error: " & exception.Errors(i).ToString() & ControlChars.NewLine)
Next i
Console.ReadLine()
End Sub
설명
이 클래스는 클래스의 SqlError 인스턴스를 수집하기 위해 만들어집니다SqlException. SqlErrorCollection 는 항상 클래스의 SqlError 인스턴스를 하나 이상 포함합니다.
속성
| Name | Description |
|---|---|
| Count |
컬렉션의 오류 수를 가져옵니다. |
| Item[Int32] |
지정된 인덱스에서 오류를 가져옵니다. |
메서드
| Name | Description |
|---|---|
| CopyTo(Array, Int32) |
지정된 인덱스에서 시작하여 컬렉션Array의 SqlErrorCollection 요소를 복사합니다. |
| CopyTo(SqlError[], Int32) |
컬렉션의 SqlErrorCollectionSqlErrorCollection요소를 지정된 인덱스에서 시작하여 컬렉션에 복사합니다. |
| Equals(Object) |
지정한 개체와 현재 개체가 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetEnumerator() |
를 반복하는 열거자를 반환합니다 SqlErrorCollection. |
| GetHashCode() |
기본 해시 함수로 작동합니다. (다음에서 상속됨 Object) |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |
명시적 인터페이스 구현
| Name | Description |
|---|---|
| ICollection.IsSynchronized |
이 멤버에 대한 설명은 을 참조하세요 IsSynchronized. |
| ICollection.SyncRoot |
이 멤버에 대한 설명은 을 참조하세요 SyncRoot. |
확장명 메서드
| Name | Description |
|---|---|
| AsParallel(IEnumerable) |
쿼리의 병렬 처리를 사용하도록 설정합니다. |
| AsQueryable(IEnumerable) |
IEnumerable IQueryable변환합니다. |
| Cast<TResult>(IEnumerable) |
IEnumerable 요소를 지정된 형식으로 캐스팅합니다. |
| OfType<TResult>(IEnumerable) |
지정된 형식에 따라 IEnumerable 요소를 필터링합니다. |