C# SQlite Connection String Format C# SQlite Connection String Format database database

C# SQlite Connection String Format


  1. You should pick the Mixed one.
  2. the 1.0.84.0 is the newest version out for the SQLite DLL. I createdan application with SQLite too in c#, my connection string lookslike the following:

    sqlite_conn = new SQLiteConnection("Data Source=C:\SQLITEDATABASES\SQLITEDB1.sqlite;Version=3;");

The version you are using, is SQLite version 3, the DLL is just a different version, but works with SQLite version 3.


The following are different type of Sqlite Connection String

Basic

Data Source=c:\mydb.db;Version=3;

Version 2 is not supported by this class library.

In-Memory DatabaseAn SQLite database is normally stored on disk but the database can also be stored in memory.

Data Source=:memory:;Version=3;New=True;

Using UTF16

Data Source=c:\mydb.db;Version=3;UseUTF16Encoding=True;

With password

Data Source=c:\mydb.db;Version=3;Password=myPassword;


SQLite is written in C. For Windows, it is distributed as a compiled 32 bit (x86) .dll. This cannot be used from .NET directly because it is native code and .NET programs don't normally like to interact with native code. It can be done with something called COM Interop, but in my hands that is not easy or pretty.

In your question you reference a download page that is for System.Data.SQLite. This is a slightly different implementation than plain old SQLite. It takes C SQLite and wraps it with .NET code - allowing use of the C native code by .NET programs (hooray, someone else did the work).

When you have both native code (the C SQLite) and .NET code (the wrapper functions) together in one assembly, that is called a mixed-mode assembly, and originally it made sense to put everything in one file. If you are doing development or only using SQLite on your own machine, then using a mixed-mode assembly is fine.

However, things have changed with 64 bit Windows IF you want to distribute your application to customers. This is because mixed-mode assemblies can only run on the architecture they were compiled for (a white lie, but true for this answer). As of version 1.0.80.0 of System.Data.SQLite, it is strongly suggested you distribute:1.) The all .NET .dll System.Data.SQLite.dll, which can run on 32 bit or 64 bit architectures)AND2.) a 32-bit .dll x86\SQLite.Interop.dllAND3. a 64 bit .dll x64\SQLite.Interop.dll

The all .NET wrapper (item 1) figures out which which architecture it is running on and picks the 32 bit or 64 bit .dll accordingly.

All this is described on the System.Data.SQLite downloads page that you referenced, but I found it confusing so I offer my summary.

The version discrepancy you note in your question is also due to the difference between SQLite and System.Data.SQLite.