Sqlite3错误:无法打开数据库文件
问题描述:
这是我第一次使用sqlite3的应用程序。我正在使用 finishar.sqlite ,一切都运行良好。
但是由于我已经推荐了应用程序的测试版,用户报告了这个错误: 无法打开数据库。
但是在一些用户的计算机和我的电脑上工作正常。
我尝试过的事情:
我试过这个:
This is my first application with sqlite3. I am using finishar.sqlite and everything works perfectly.
But since I've realesed my app's beta version, users reported this error:Unable to open database.
But on some user's computers and my computer it's working fine.
What I have tried:
I tried this:
public static DataTable veriAl(string sqliteKomut)
{
DataTable dt = new DataTable();
using (SQLiteConnection sqlCon = new SQLiteConnection("Data Source=" + Application.StartupPath + "\\Veri\\tkt.db;Version=3;New=False;Compress=True;UTF8Encoding=True;DateTimeFormat=CurrentCulture"))
{
sqlCon.Open();
sqlDa = new SQLiteDataAdapter(sqliteKomut, sqlCon);
}
sqlDa.Fill(dt);
return dt;
}
和这个样式代码
and this style codes
SQLiteConnection sqlCon = new SQLiteConnection("Data Source=" + Application.StartupPath + "\\Veri\\tkt.db;Version=3;New=False;Compress=True;UTF8Encoding=True;DateTimeFormat=CurrentCulture");
public static DataTable veriAl(string sqliteKomut)
{
DataTable dt = new DataTable();
sqlCon.Open();
sqlDa = new SQLiteDataAdapter(sqliteKomut, sqlCon);
sqlCon.Close();
sqlDa.Fill(dt);
return dt;
}
答
确保数据库文件正常,您可以在sqlite查看器中打开它,并且文件未被锁定或正在使用。
Make sure the database file is ok and you can open it in a sqlite viewer, and the file is not locked or in use.