.NET Framework Class Library  

SqlCeError Class

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

Collects information relevant to a warning or error returned by the data source. This class cannot be inherited.

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

System.Object
   System.Data.SqlServerCe.SqlCeError

[Visual Basic]
NotInheritable Public Class SqlCeError
[C#]
public sealed class SqlCeError
[C++]
public __gc __sealed class SqlCeError
[JScript]
public class SqlCeError

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

An instance of SqlCeError is created by the System.Data.SqlServerCe managed provider when an error occurs. The SqlCeErrorCollection contains one or more instances of SqlCeError.

Example

[Visual Basic, C#] The following example displays the properties of the SqlCeError.

[Visual Basic] 
Public Shared Sub ShowErrors(e As SqlCeException)
   Dim errorCollection As SqlCeErrorCollection = e.Errors
   
   Dim bld As New StringBuilder()
   Dim inner As Exception = e.InnerException
   
   If Not inner is Nothing Then
      MessageBox.Show(("Inner Exception: " & inner.ToString()))
   End If
   
   Dim err As SqlCeError
   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 

[C#] 
public static void ShowErrors(SqlCeException e) {
    SqlCeErrorCollection errorCollection = e.Errors;

    StringBuilder bld = new StringBuilder();
    Exception   inner = e.InnerException;

    if (null != inner) {
        MessageBox.Show("Inner Exception: " + inner.ToString());
    }

    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

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