SqlCeErrorCollection Class

Coleta todos os erros gerados pelo Provedor de Dados do .NET Compact Framework para SQL Server Compact 3.5. Esta classe não pode ser herdada.

Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (em system.data.sqlserverce.dll)

Sintaxe

'Declaração
<DefaultMemberAttribute("Item")> _
Public NotInheritable Class SqlCeErrorCollection
    Implements ICollection, IEnumerable
[DefaultMemberAttribute("Item")] 
public sealed class SqlCeErrorCollection : ICollection, IEnumerable
[DefaultMemberAttribute(L"Item")] 
public ref class SqlCeErrorCollection sealed : ICollection, IEnumerable
/** @attribute DefaultMemberAttribute("Item") */ 
public final class SqlCeErrorCollection implements ICollection, IEnumerable
DefaultMemberAttribute("Item") 
public final class SqlCeErrorCollection implements ICollection, IEnumerable

Comentários

Esta classe é criada pela SqlCeException para coletar instâncias da classe SqlCeError. A SqlCeErrorCollection sempre contém pelo menos uma instância da classe SqlCeError.

Hierarquia de herança

System.Object
  System.Data.SqlServerCe.SqlCeErrorCollection

Exemplo

O exemplo a seguir exibe cada SqlCeError da coleção SqlCeErrorCollection.

Public Sub DisplaySqlCeErrors(ByVal errorCollection As SqlCeErrorCollection)

    Dim err As SqlCeError
    Dim bld As New StringBuilder()

    For Each err In errorCollection
        bld.Append((ControlChars.Cr & " Error Code: " & err.HResult.ToString("X")))
        bld.Append((ControlChars.Cr & " Message   : " & err.Message))
        bld.Append((ControlChars.Cr & " Minor Err.: " & err.NativeError))
        bld.Append((ControlChars.Cr & " Source    : " & err.Source))

        Dim numPar As Integer
        For Each numPar In err.NumericErrorParameters
            If 0 <> numPar Then
                bld.Append((ControlChars.Cr & " Num. Par. : " & numPar))
            End If
        Next numPar

        Dim errPar As String
        For Each errPar In err.ErrorParameters
            If [String].Empty <> errPar Then
                bld.Append((ControlChars.Cr & " Err. Par. : " & errPar))
            End If
        Next errPar

        MessageBox.Show(bld.ToString())
        bld.Remove(0, bld.Length)
    Next err

End Sub 'DisplaySqlCeErrors
public void DisplaySqlCeErrors(SqlCeErrorCollection errorCollection ) {
    StringBuilder bld = new StringBuilder();

    foreach (SqlCeError err in errorCollection) {
        bld.Append("\n Error Code: " + err.HResult.ToString("X"));
        bld.Append("\n Message   : " + err.Message);
        bld.Append("\n Minor Err.: " + err.NativeError);
        bld.Append("\n Source    : " + err.Source);
            
        foreach (int numPar in err.NumericErrorParameters) {
            if (0 != numPar) bld.Append("\n Num. Par. : " + numPar);
        }
            
        foreach (string errPar in err.ErrorParameters) {
            if (String.Empty != errPar) bld.Append("\n Err. Par. : " + errPar);
        }

        MessageBox.Show(bld.ToString());
        bld.Remove(0, bld.Length);
    }
}

Segurança de thread

Quaisquer membros estáticos públicos (compartilhados no Microsoft Visual Basic) desse tipo são thread safe. Não há garantia de que qualquer membro de instância seja thread safe.

Plataformas

Plataformas de desenvolvimento

Windows Vista, Windows Mobile 5.0, Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Mobile 2003 for Pocket PC, Windows CE 5.0
Informações de versão
.NET Framework e NET Compact Framework
Com suporte no 3.5
.NET Framework
Com suporte no 3.0
.NET Compact Framework e .Net Framework
Com suporte no 2.0

Consulte também

Referência

SqlCeErrorCollection Members
System.Data.SqlServerCe Namespace
SqlCeError Class
SqlCeException