SqlCeException.Message 属性

获取描述此异常的 SqlCeErrorCollection 中的第一个 SqlCeError 实例的文本。

命名空间:  System.Data.SqlServerCe
程序集:  System.Data.SqlServerCe(在 System.Data.SqlServerCe.dll 中)

语法

声明
Public Overrides ReadOnly Property Message As String
    Get
用法
Dim instance As SqlCeException
Dim value As String

value = instance.Message
public override string Message { get; }
public:
virtual property String^ Message {
    String^ get () override;
}
abstract Message : string
override Message : string
override function get Message () : String

属性值

类型:System.String
对错误进行描述的文本。

实现

_Exception.Message

注释

这与此异常的 SqlCeErrorCollection 中第一个 SqlCeError 实例的 Message 属性相同。

示例

下面的示例显示了 SqlCeErrorCollection 集合中第一个 SqlCeErrorMessageNativeError 属性。

Try
    Dim repl As 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 e As SqlCeException
    Dim err As SqlCeError
    For Each err In e.Errors
        ' Use SqlCeError properties if you need specific
        ' application logic depending on the error condition
        '
        If 28577 = [err].NativeError Then 'SSCE_M_SCHEMAHASCHANGED
            ' Error specific logic goes here...
            '
        End If

        ' Note: For native error numbers, refer to SQL Server Mobile Errors
        ' in the SQL Server Mobile Books Online
        '
        MessageBox.Show([err].Message)
    Next err
End Try
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);
    }
}

请参阅

参考

SqlCeException 类

System.Data.SqlServerCe 命名空间