使用 System.Data.Sqlite 获取未提交的事务 Sqlite
我正在尝试使用 System.Data.Sqlite 库获取 SQLite 数据库中未提交记录的计数。到目前为止,我的研究指向使用 PRAGMA read_commissed,但在提交记录之前我总是得到 0 计数。有什么建议吗?
using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + this.Path))
{
conn.Open();
using (SQLiteCommand cmd = new SQLiteCommand(conn))
{
cmd.CommandText = "PRAGMA read_uncommitted = true;";
cmd.ExecuteNonQuery();
cmd.CommandText = "SELECT Count() FROM Tiles WHERE TileLayerId = " + tileLayerId;
return Convert.ToInt32(cmd.ExecuteScalar());
}
}
I am trying to get a count of uncommitted records in a SQLite database using the System.Data.Sqlite library. My research thus far has pointed towards using the PRAGMA read_committed, but I always get a count of 0 until records are committed. Any tips?
using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + this.Path))
{
conn.Open();
using (SQLiteCommand cmd = new SQLiteCommand(conn))
{
cmd.CommandText = "PRAGMA read_uncommitted = true;";
cmd.ExecuteNonQuery();
cmd.CommandText = "SELECT Count() FROM Tiles WHERE TileLayerId = " + tileLayerId;
return Convert.ToInt32(cmd.ExecuteScalar());
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论