防止SQLITE完全关闭连接(C#)
在WPF应用中,我正在创建与本地加密数据库(使用Microsoft.data.sqlite)的连接:
string builder = new SqliteConnectionStringBuilder($"Data Source=source.sqlite; Password='{password}';")
{
Mode = SqliteOpenMode.ReadOnly
}.ToString();
每个查询都使用 block包裹在中。
问题在于,在应用程序上不活动5到10分钟之后,SQLite似乎可以关闭与数据库的连接,因为下一个查询需要至第一个查询(打开应用程序时,这是正常的,我想)。
我尝试使用sqliteconnectionstringbuilder
的参数,例如cache
或pliming
,但没有成功。
可以防止这种情况发生吗?
In a WPF app, I'm creating a connection to a local encrypted database (using Microsoft.Data.Sqlite):
string builder = new SqliteConnectionStringBuilder(quot;Data Source=source.sqlite; Password='{password}';")
{
Mode = SqliteOpenMode.ReadOnly
}.ToString();
Each query is wrapped in a using
block.
The problem is that after 5 to 10 minutes of inactivity on the app, SQLite seems to close the connection to the database as the next query takes as long as the first one (when opening the app, which is normal, I guess).
I tried playing with the parameters of the SqliteConnectionStringBuilder
such as Cache
or Pooling
, but no success.
Would it be possible to prevent this from happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论