SQLiteConnection - ConnectionString

 

Description

This property is used to set the database-file and database options.

The ConnectionString can only be set when the Connection is closed.

The ConnectionString cannot be set to null.

The Format of the ConnectionString is: "AttributeName1=value1;AttributeName2=value2;..."

 

ConnectionString Attributes

Data Source

The filename of the database (eg. "c:\test.db")

Version

"2" - SQLite 2.x (default)

"3" - SQLite 3.x

New

"True" - If the database already exists, it is deleted and a new database is created

"False" (default) - An existing database file is used

Compress

"True" - Enables NTFS-File-Compression if a windows machine with NTFS filesystem is used

"False" (default) - Does not enable NTFS-File-Compression

UTF8Encoding

"True" - Uses UFT8-Encoding

"False" (default) - Does not use UFT8-Encoding

UTF16Encoding

"True" - Uses UFT16-Encoding

"False" (default) - Does not use UFT16-Encoding

Cache Size

default: 2000

This setting is passed to SQLite. Their website says:

[..] number of database disk pages that SQLite will hold in memory at once. Each page uses about 1.5K of memory. The default cache size is 2000. If you are doing UPDATEs or DELETEs that change many rows of a database and you do not mind if SQLite uses more memory, you can increase the cache size for a possible speed improvement.

Related Link: http://www.sqlite.org/pragma.html

Synchronous

"Full"

"Normal" (default)

"Off"

This value is passed to SQLite - See "PRAGMA synchronous;" in the SQLite-Documentation!

Related Link: http://www.sqlite.org/pragma.html

DateTimeFormat

"ISO8601" (default)

"Ticks"

"CurrentCulture"

Compatibility

[old-date-format,old-binary-format]

This value is empty by default.

 

Example Code

using Finisar.SQLite;
 
// [snip] - As C# is purely object-oriented the following lines must be put into a class:
 
SQLiteConnection sqlite_conn; // Declare the SQLiteConnection-Object

sqlite_conn = new SQLiteConnection(); // Create an instance of the object
sqlite_conn.ConnectionString = "Data Source=c:\\test-database.db;Version=3;New=True;Compress=True;"; // Set the ConnectionString
sqlite_conn.Open(); // Open the connection. Now you can fire SQL-Queries