如何在 C# Windows Phone App with SQLitePCL 中检查插入操作是否成功

How to check whether a insert operation is successful or not in C# Windows Phone App with SQLitePCL

我在 Windows Phone 应用程序中使用 SQLitePCL 作为本地数据库。我需要检查数据库中的 insert operation 是成功还是失败。我该如何检查?

我正在尝试按照以下代码片段进行插入:

using ( var connection = new SQLiteConnection(DbController.DB_NAME))
{
    using( var statemant = connection.Prepare(sql)) //sql is the string containing SQL command prepared earlier
    {
        statemant.Step();
    }
}

我在 statement 对象中找不到任何包含成功状态的 属性 或方法。有没有办法获得成功状态?

statemant.Step() 应该 return 一个 SQLiteResult enum。您可以检查结果是否等于 OK.

SQLiteResult result = statemant.Step();
if(result != SQLiteResult.OK)
{
    throw new Exception();
}