单声道连接字符串

时间:2013-03-07 10:07:25

标签: sqlite mono connection-string

我正在尝试从我的单声道应用程序连接到Sqlite数据库,但在尝试打开连接时我一直收到此错误。

System.FormatException: Input string was not in the correct format

这是我的连接字符串:

String connString = @"Data Source=C:\Users\pc_user\Desktop\Folder\Database.db;Version=2.2;Password=xxx;";

我设法连接到我的数据库(经过无数的工时),但现在我无法将记录插入其中。我收到了这个模棱两可的错误:

System.ArgumentException: element already exists

帮助,任何人

2 个答案:

答案 0 :(得分:1)

根据Connectionstring.com(宝贵的资源):对于SQLite 2.x(默认),“Version”键可以取值“2”,对于SQLite 3.x,取值“3”

你试过吗

String connString = @"Data Source=C:\Users\pc_user\Desktop\Folder\Database.db;Version=2.2;Password=xxx;";

答案 1 :(得分:0)

鱼饼是对的:你应该将版本设置为2或3。

您可以尝试将连接字符串更改为:

    String connString = @"Data Source=file:C:\Users\pc_user\Desktop\Folder\Database.db;Version=2;Password=xxx;"

(更改是在数据源之后添加“file:”)。 如果它不起作用,你可以试试

    String connString = @"URI=file:C:\Users\pc_user\Desktop\Folder\Database.db;Version=2;Password=xxx;"

并且,您仍然遇到相同的错误,您是否可以尝试使用无密码数据库(并从连接字符串中删除密码= )?