Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is wrong with the sql lite connection string?

Tags:

sqlite

very new to sql lite,

I want to use it for a small project, get some overview, and try to implement but i got error while use following connection string?

Can some one please tell me what is wrong and what changes i need to do when i will set the path from web.config for sql lite connection string.

 SQLiteConnection connection = new SQLiteConnection("D:\\Projects\\Apica MVC\\wizardDemo\\Apica.Signupweb.Presentation.MvcWeb\\App_Data\\SignUpWebDB");

i got an error.......

"Invalid ConnectionString format for parameter "D:\Projects\Apica MVC\wizardDemo\Apica.Signupweb.Presentation.MvcWeb\App_Data\SignUpWebDB""

There is no password set for string.

like image 249
amit patel Avatar asked Jan 24 '12 08:01

amit patel


People also ask

What is SQLiteConnection?

SQLiteConnection is a single connection to sqlite database. It wraps the sqlite3* database handle from SQLite C Interface. Unless otherwise specified, methods are confined to the thread that was used to open the connection.

How do I connect to a SQLite database?

Select SQLite from the list. Give a Connection name for your own internal reference. For Database , click Choose a File and then select the database file on your local machine to which you want to connect. Hit Connect and you're all set!

Does SQLite allow multiple connections?

SQLite does support multiple concurrent connections, and therefore it can be used with a multi-threaded or multi-process application. The catch is that when SQLite opens a write transaction, it will lock all the tables.


1 Answers

Your connection string isn't correctly formatted.

You're specifying the full path and filename of the database file, but you need to ensure that you include the Data source= part of the connection string in front of the actual database path and filename (also notice the semi-colon at the end of the connection string before the closing quote).

For example:

SQLiteConnection connection = new SQLiteConnection("Data Source=D:\\Projects\\Apica MVC\\wizardDemo\\Apica.Signupweb.Presentation.MvcWeb\\App_Data\\SignUpWebDB;");

There are more parameters that you can specify within a SQLite Connection string, see this link from the old System.Data.SQLite forums for further information. The complete documentation for the System.Data.SQLite package can be found at this page. The source code file (amongst others) contains the SQLite.NET.chm documentation file.

like image 144
CraigTP Avatar answered Jan 02 '23 16:01

CraigTP