[英]Attempt to write a readonly database After of 20 minutes of repeated queries
我的應用程序每3秒對SQLite
數據庫進行一次查詢,但是大約20分鍾之后,在執行命令時,它會引發異常"Attempt to write a readonly database"
。 我只需要閱讀數據庫。
進口:
using System.Data.Sqlite;
這是我的連接字符串:
sqlite_conn = new SQLiteConnection("Data Source=Patch_here;Version=3;Compress=True;Read Only=True"
這是拋出異常的方法。 此方法每3秒執行一次:
Double fecha = 0;
try
{
sqlite_cmd = new SQLiteCommand(sqlite_conn);
sqlite_cmd.CommandText = "SELECT MAX(timestamp) FROM Messages";
//HERE throws the exception, when executes the command.
fecha = Double.Parse(sqlite_cmd.ExecuteScalar().ToString());
sqlite_cmd.Dispose();
}
catch (Exception ex)
{
informarError(ex.Message);
}
return timestamp_To_Datetime(fecha);
此外,-我的用戶擁有此數據庫的所有特權。 -我的SQLiteConnection只是為所有查詢打開一次。
我能做什么? 謝謝。
(我知道,這已經很老了。也許這對另一個人有幫助。)
我有一個類似的問題:數據庫處於(寫入)負載下(已填充C / C ++程序)。 同時,C#程序會定期發送選擇計數(*)。 有時(非常少見),但提到的錯誤除外。
我通過從連接字符串中刪除“ Read Only = True”來“解決”此問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.