Jeffwn
Jeffwn

Reputation: 1

Mono Connection string

I am trying to connect to an Sqlite db from my mono app but I keep getting this error when trying to open the connection.

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

Here is my connection string:

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

I managed to connect to my db(after countless man-hours) but now I can't insert records into it.I get this ambiguous error:

System.ArgumentException: element already exists

Help,anyone

Upvotes: 0

Views: 1357

Answers (2)

mbarthelemy
mbarthelemy

Reputation: 12913

Fishcake is right : you should set Version to either 2 or 3.

Could you try changing your connection string to:

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

(the change is to add "file:" after data source). If it doesn't work, can you try with

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

And, you keep having the same error, could you try with a password-less database (and removing the Password= from your connection string)?

Upvotes: 0

Fishcake
Fishcake

Reputation: 10774

According to Connectionstring.com (an invaluable resource): The "Version" key can take value "2" for SQLite 2.x (default) or value "3" for SQLite 3.x

Have you tried

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

Upvotes: 1

Related Questions