【发布时间】:2012-08-15 21:55:30
【问题描述】:
我正在使用 Windows 8 发布预览版和 C#(VS 2012) 开发 Metro 应用程序,我是 SQLite 新手,我在我的应用程序中集成了 SQLite 3.7.13,它运行良好,请查看下面的代码
var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Test.db");
using (var db = new SQLite.SQLiteConnection(dbPath))
{
var data = db.Table<tablename>().Where(tablename => tablename.uploaded_bool == false && tablename.Sid == 26);
try
{
int iDataCount = data.Count();
int id;
if (iDataCount > 0)
{
for (int i = 0; i < iDataCount; i++)
{
Elements = data.ElementAt(i);
id = Elements.id;
/*
Doing some code
*/
}
int i = db.Delete<tablename>(new tablename() { Sid = 26 });
}
}
catch (Exception ex)
{
}
}
其中“Sid”是我数据库中的列,编号为“26”我将获得 n 行 所以,使用 for 循环我需要做一些代码,在 for 循环之后我需要删除数据库中 Sid(26) 的记录,所以在这一行
int i = db.Delete<tablename>(new tablename() { Sid = 26 });
我收到unable to close due to unfinalised statements 异常,所以我的问题是如何在 sqlite3 中完成语句,显然 SQLite3 有一个用于销毁以前的 DB 调用的 finalize 方法,但我不确定如何实现这一点。请帮帮我。
【问题讨论】:
标签: c# sqlite windows-8 microsoft-metro windows-runtime