简体   繁体   English

无法在sqlite中打开数据库文件(使用finisar.sqlite)

[英]unable to open database file in sqlite (using finisar.sqlite)

I am using sqlite database with sqlite.net dll in my application. 我在我的应用程序中使用sqlite.net dllsqlite.net dll Namespace is Finisar.sqlite I have problem while inserting entries in to database using transaction, It throws exception at open connection as "unable to open database file". 命名空间是Finisar.sqlite我在使用事务将条目插入数据库时遇到问题,它在打开连接时抛出异常为“无法打开数据库文件”。

I google it but solutions are like change connection string. 我谷歌它,但解决方案就像更改连接字符串。 if i follow that process then finisar gives me exception as invalid params. 如果我遵循这个过程,那么finisar会将异常作为无效的params。

SQLiteConnection db = new SQLiteConnection(f_strConnStr);

db.Open();

**Valid parameters are:** 

Data Source=<database file>  (required)

Version=<version of SQLite (2 or 3)>            (default: 2)

New=True|False                  (default: False)

Compress=True|False                 (default: False)

UTF8Encoding=True|False             (default: False)

UTF16Encoding=True|False            (default: False)

Cache Size=<N>                  (default: 2000)

Synchronous=Full|Normal|Off             (default: Normal)

DateTimeFormat=ISO8601|Ticks|CurrentCulture     (default: ISO8601)

Compatibility=[old-date-format][,old-binary-format] (default: None)

I tried solution like pooling connection string, journal mode = off etc but nothing works for me. 我尝试了解决方案,如池连接字符串,日志模式=关闭等,但没有任何对我有用。 even i can not create file which is password protected due to invalid parameter. 即使我无法创建由于参数无效而受密码保护的文件。

I can not add other than this parameters. 我不能添加除此参数以外的其他内容。 If anyone having solution regarding this issue please help us. 如果有人对此问题有解决方案,请帮助我们。

Thanks in advance. 提前致谢。

So a number of things could be going wrong here: 所以有很多事情可能会出错:

  1. The folder the SQLite database is in, you don't have Write permissions to. SQLite数据库所在的文件夹,您没有写入权限。
  2. The database is already open by another SQLiteConnection . 该数据库已由另一个SQLiteConnection打开。
  3. The connection string is wrong. 连接字符串错误。 I think this one is unlikely because it's clearly a variable you're pulling the connection string from and I have to believe other times you wanted data you used the same string. 我认为这个不太可能,因为它显然是一个变量,你正在拉动连接字符串,我不得不相信其他时候你想要使用相同字符串的数据。

To remedy #2 you should always access your data like this: 要解决#2,您应该始终访问您的数据,如下所示:

using (SQLiteConnection c = new SQLiteConnection(f_strConnStr))
{
    c.Open();
    ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM