Share via


SqlCeError クラス

データ ソースが返す警告またはエラーに関する情報を収集します。このクラスは継承できません。

名前空間:  System.Data.SqlServerCe
アセンブリ:  System.Data.SqlServerCe (System.Data.SqlServerCe.dll)

構文

'宣言
Public NotInheritable Class SqlCeError
'使用
Dim instance As SqlCeError
public sealed class SqlCeError
public ref class SqlCeError sealed
[<SealedAttribute>]
type SqlCeError =  class end
public final class SqlCeError

説明

SqlCeError のインスタンスは、エラーが発生したときに System.Data.SqlServerCe マネージ プロバイダによって作成されます。SqlCeErrorCollection には、SqlCeError のインスタンスが 1 つ以上格納されます。

使用例

SqlCeError の一般的な使用例を次に示します。

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

継承階層

System. . :: . .Object
  System.Data.SqlServerCe..::..SqlCeError

スレッド セーフ

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.

関連項目

参照

SqlCeError メンバー

System.Data.SqlServerCe 名前空間

SqlCeErrorCollection

SqlCeException