Export (0) Print
Expand All

SqlCeException.Message Property

Gets the text describing the first instance of SqlCeError in the SqlCeErrorCollection for this exception.

Namespace:  System.Data.SqlServerCe
Assembly:  System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)

public override string Message { get; }

Property Value

Type: System.String
The text describing the error.

Implements

_Exception.Message

This is the same as the Message property of the first instance of SqlCeError in the SqlCeErrorCollection for this exception.

The following example displays the Message and NativeError properties of the first SqlCeError within the SqlCeErrorCollection collection.

try
{
    SqlCeReplication repl = new SqlCeReplication();

    // Fill repl properites here
    // ...

    // SqlCeReplication may throw SqlCeException which contains a 
    // collection of errors; SQL Mobile database engine always
    // returns one error in the collection
    //
    repl.Synchronize();
}
catch (SqlCeException e)
{
    foreach (SqlCeError error in e.Errors)
    {
        // Use SqlCeError properties if you need specific
        // application logic depending on the error condition
        //
        if (28577 == error.NativeError /*SSCE_M_SCHEMAHASCHANGED*/)
        {
            // Error specific logic goes here...
            //
        }

        // Note: For native error numbers, refer to SQL Server Mobile Errors
        // in the SQL Server Mobile Books Online
        //
        MessageBox.Show(error.Message);
    }
}


Show:
© 2015 Microsoft