Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SqlCeException Class

The exception thrown when the underlying provider returns a warning or error from a SQL Server Compact data source. This class cannot be inherited.

Namespace:  System.Data.SqlServerCe
Assembly:  System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)
[SerializableAttribute]
public class SqlCeException : DbException

The SqlCeException type exposes the following members.

  NameDescription
Protected methodSqlCeExceptionConstructor that helps in serialization.
Top
  NameDescription
Public propertyData (inherited from Exception)
Public propertyErrorCode (inherited from ExternalException)
Public propertyErrorsGets a collection of one or more SqlCeError objects that contain detailed information about exceptions generated by the .NET Compact Framework Data Provider for SQL Server Compact.
Public propertyHelpLink (inherited from Exception)
Public propertyHResultGets the HRESULT value of the exception. This value is the same as the value of HResult for the first instance of SqlCeError in the SqlCeErrorCollection for the exception.
Public propertyInnerException (inherited from Exception)
Public propertyMessageGets the text describing the first instance of SqlCeError in the SqlCeErrorCollection for this exception. (Overrides Exception.Message.)
Public propertyNativeErrorGets the native error number of the first SqlCeError in the SqlCeErrorCollection. For more information about the error, see the "SQL Server Compact Errors" topic in the Troubleshooting section of SQL Server Compact Books Online.
Public propertySourceGets the name of the OLE DB provider that generated the error. (Overrides Exception.Source.)
Public propertyStackTrace (inherited from Exception)
Public propertyTargetSite (inherited from Exception)
Top
  NameDescription
Public methodEquals (inherited from Object)
Protected methodFinalize (inherited from Object)
Public methodGetBaseException (inherited from Exception)
Public methodGetHashCode (inherited from Object)
Public methodGetObjectDataSecurity Critical. Populates a SerializationInfo with the data required to serialize the object. (Overrides Exception.GetObjectData(SerializationInfo, StreamingContext).)
Public methodGetType (inherited from Exception)
Protected methodMemberwiseClone (inherited from Object)
Public methodToString (inherited from Exception)
Top

This class is created whenever the .NET Compact Framework Data Provider for SQL Server Compact encounters an error generated from within the SQL Server Compact Engine. (Other errors are thrown as standard common language runtime exceptions.) SqlCeException always contains at least one instance of SqlCeError.

The following example generates a SqlCeException due to a missing data source, and then displays the exception.

SqlCeConnection conn = new SqlCeConnection("Data Source=nonExistingSource.sdf;");

try
{
    conn.Open();
}
catch (SqlCeException e)
{
    // Use SqlCeException properties if you need specific
    // application logic depending on the error condition
    //
    if (25046 == e.NativeError /*SSCE_M_FILENOTFOUND*/)
    {
        // Error specific logic goes here...
        //
    }

    MessageBox.Show(e.Message);
}


Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.