Compartir a través de


SqlCeException.NativeError Propiedad

Obtiene el número de error nativo del primer SqlCeError de SqlCeErrorCollection. Para obtener más información acerca del error, vea el tema sobre errores de SQL Server Compact en la sección de solución de problemas de los Libros en pantalla de SQL Server Compact.

Espacio de nombres:  System.Data.SqlServerCe
Ensamblado:  System.Data.SqlServerCe (en System.Data.SqlServerCe.dll)

Sintaxis

'Declaración
Public ReadOnly Property NativeError As Integer
    Get
'Uso
Dim instance As SqlCeException
Dim value As Integer

value = instance.NativeError
public int NativeError { get; }
public:
property int NativeError {
    int get ();
}
member NativeError : int
function get NativeError () : int

Valor de la propiedad

Tipo: System.Int32
Devuelve Int32.

Ejemplos

En el siguiente ejemplo se muestran las propiedades Message y NativeError del primer SqlCeError de la colección SqlCeErrorCollection.

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);
    }
}

Vea también

Referencia

SqlCeException Clase

Espacio de nombres System.Data.SqlServerCe