Share via


Classe SqlCeErrorCollection

Raccoglie tutti gli errori generati dal provider di dati .NET Compact Framework per SQL Server Compact. Questa classe non può essere ereditata.

Gerarchia di ereditarietà

System.Object
  System.Data.SqlServerCe.SqlCeErrorCollection

Spazio dei nomi  System.Data.SqlServerCe
Assembly:  System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)

Sintassi

'Dichiarazione
<SerializableAttribute> _
Public NotInheritable Class SqlCeErrorCollection _
    Implements ICollection, IEnumerable
'Utilizzo
Dim instance As SqlCeErrorCollection
[SerializableAttribute]
public sealed class SqlCeErrorCollection : ICollection, 
    IEnumerable
[SerializableAttribute]
public ref class SqlCeErrorCollection sealed : ICollection, 
    IEnumerable
[<SealedAttribute>]
[<SerializableAttribute>]
type SqlCeErrorCollection =  
    class
        interface ICollection
        interface IEnumerable
    end
public final class SqlCeErrorCollection implements ICollection, IEnumerable

Nel tipo SqlCeErrorCollection sono esposti i membri seguenti.

Proprietà

  Nome Descrizione
Proprietà pubblica Count Ottiene il numero di oggetti SqlCeError contenuti nella raccolta.
Proprietà pubblica Item Ottiene l'errore in corrispondenza dell'indice specificato.

In alto

Metodi

  Nome Descrizione
Metodo pubblico CopyTo Copia gli elementi dell'oggetto SqlCeErrorCollection in un oggetto Array, partendo dall'indice specificato all'interno dell'oggetto Array.
Metodo pubblico Equals (ereditato da Object)
Metodo protetto Finalize (ereditato da Object)
Metodo pubblico GetEnumerator Infrastruttura. Restituisce un enumeratore che consente di scorrere l'oggetto SqlCeErrorCollection.
Metodo pubblico GetHashCode (ereditato da Object)
Metodo pubblico GetType (ereditato da Object)
Metodo protetto MemberwiseClone (ereditato da Object)
Metodo pubblico ToString (ereditato da Object)

In alto

Implementazioni esplicite dell'interfaccia

  Nome Descrizione
Implementazione esplicita dell'interfacciaProprietà privata ICollection.IsSynchronized
Implementazione esplicita dell'interfacciaProprietà privata ICollection.SyncRoot

In alto

Osservazioni

Questa classe viene creata dalla classe SqlCeException per raccogliere istanze della classe SqlCeError. La classe SqlCeErrorCollection contiene sempre almeno un'istanza della classe SqlCeError.

Esempi

Nell'esempio seguente viene visualizzato ogni oggetto SqlCeError all'interno della raccolta 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);
    }
}

Protezione dei thread

I membri statici pubblici (Shared in Microsoft Visual Basic) di questo tipo sono thread-safe. Non è invece garantita la sicurezza dei membri dell'istanza.

Vedere anche

Riferimento

Spazio dei nomi System.Data.SqlServerCe

SqlCeError

SqlCeException