【问题标题】:SQLite with c# Metro app CRUD operation Syntax?SQLite 与 c# Metro app CRUD 操作语法?
【发布时间】:2012-09-23 18:42:25
【问题描述】:

我正在制作一个 Windows 8 Metro 应用程序。我将 SQLite 用于数据库目的。 我在某处读到要插入数据库的内容,请使用以下命令:

 db.Insert(new Person() { FirstName = "Tim", LastName = "Heuer" });

现在我需要删除和更新的语法

我试过了,但是错误来了:

db.Delete(new Tasks() { Title = "dixit" });

提前致谢

【问题讨论】:

  • 您需要添加更多细节。您的 SQLite 数据库架构是什么(使用数据库文件打开 SQLite,并从 SQLite 控制台输入.schema)? db的类型是什么,如何初始化?您看到的错误是什么(最好是堆栈跟踪)?

标签: c# sqlite xaml microsoft-metro


【解决方案1】:

你可以用这个:

        var db = new SQLite.SQLiteAsyncConnection(DBPath);

        // Empty the Customer and Project tables 
        var customers = await db.Table<Customer>().ToListAsync();
        foreach (Customer customer in customers)
        {
            await db.DeleteAsync(customer);
        }

【讨论】:

    猜你喜欢
    • 2015-03-28
    • 2018-06-08
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-11
    • 2015-05-21
    相关资源
    最近更新 更多