.NET Framework Class Library  

SqlCeErrorCollection Class

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Collects all errors generated by the .NET Compact Framework Data Provider for SQL Server CE. This class cannot be inherited.

For a list of all members of this type, see SqlCeErrorCollection Members.

System.Object
   System.Data.SqlServerCe.SqlCeErrorCollection

[Visual Basic]
NotInheritable Public Class SqlCeErrorCollection
   Implements ICollection, IEnumerable
[C#]
public sealed class SqlCeErrorCollection : ICollection, IEnumerable
[C++]
public __gc __sealed class SqlCeErrorCollection : public
   ICollection, IEnumerable
[JScript]
public class SqlCeErrorCollection implements ICollection,
   IEnumerable

Thread Safety

Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Remarks

This class is created by SqlCeException to collect instances of the SqlCeError class. SqlCeErrorCollection always contains at least one instance of the SqlCeError class.

Example

[Visual Basic, C#] The following example displays each SqlCeError within the SqlCeErrorCollection collection.

[Visual Basic] 
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

[C#] 
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);
    }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Data.SqlServerCe

Platforms: .NET Compact Framework - Windows CE .NET

Assembly: System.Data.Sqlserverce (in System.Data.Sqlserverce.dll)

See Also

SqlCeErrorCollection Members | System.Data.SqlServerCe Namespace | SqlCeError | SqlCeException