If you need to choose which data provider for SQLite to use with dotConnect Universal, we recommend using dotConnect for SQLite because of its obvious advantages. This article provides a brief overview of dotConnect for SQLite, describes some useful features and helps you get started quickly.
dotConnect for SQLite is a full-featured 100% managed ADO.NET data provider for the .NET Framework and the .NET Compact Framework. dotConnect for SQLite is acknowledged as the leading ADO.NET data provider for SQLite, and it has many advantages over any rival product. The main features of dotConnect for SQLite are:
The full list of dotConnect for SQLite features can be found on the product page.
The Professional Edition of dotConnect Universal includes dotConnect for SQLite as a bundled provider. The Trial Edition includes trial dotConnect for SQLite Data Provider as well. For Standard Edition of dotConnect Universal, the dotConnect for SQLite Data Provider should be purchased and installed separately.
dotConnect Universal is compatible with dotConnect for SQLite version 2.00 and above.
To deploy applications written with dotConnect Universal, copy the run-time assemblies Devart.Data.Universal.dll and Devart.Data.Universal.SQLite.dll to target machine. If you are using the standalone (not bundled) dotConnect for SQLite Data Provider, you will also have to deploy its Devart.Data.SQLite.dll assembly.
These assemblies can be registered at the Global Assembly Cache (GAC) for the appropriate .NET Framework or placed in the folder of your application.
For web projects, you may also need to deploy the Devart.Data.Universal.Web.dll, Devart.Data.SQLite.Web.dll and App_Licenses.dll assemblies. The *.Web.dll assemblies are required for using the ASP.NET Provider Model and the App_Licenses.dll assembly is a part of licensing mechanism.
Web projects are usually run as partially trusted code. The following permissions are required by dotConnect Universal and dotConnect for SQLite: medium trust plus ReflectionPermission.
Suppose you want to connect in Direct mode to the D:\TestApplication\database.db database and want to create the database in case it does not exist. In this case your connection string would look like this:
Data Source=D:\TestApplication\database.db;FailIfMissing=False;
The following table enumerates most important connection string parameters.
Name | Description |
---|---|
Data Source | The location of SQLite database file |
Connect Timeout -or- Connection Timeout | The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error. The default value is 15. |
Connection Lifetime | When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by Connection Lifetime. The default value is 0 (connection always returns to pool). |
Encryption | Determines whether the database is encrypted and kind of the database encryption. |
Max Pool Size | The maximum number of connections allowed in the pool. Setting the Max Pool Size value of the ConnectionString can affect performance. The default value is 100. |
Min Pool Size | The minimum number of connections allowed in the pool. The default value is 0. |
Password | The password for the encrypted database. |
Pooling | If true, by default, the connection object is drawn from the appropriate pool or is created and added to the appropriate pool. |
UTF16 | If true, sets the UTF16 encoding for the connection, otherwise, UTF8 encoding is set. |
To get up and running quickly, you have to perform the following steps:
That's all you need to start executing queries on the server. Below is a code fragment that illustrates steps 2-5. It also shows how to perform INSERT and SELECT operations.
dotConnect for SQLite does not support the UniSQL except the IF operator. Use SQLite predefined macro to build conditional UniSQL statements. For more information refer to the UniSQL topic.
The following table shows how the UniDbType enumeration maps to the SQLite database type.
UniDbType | SQLite data type |
---|---|
BigInt | BIGINT |
Binary | BLOB |
Bit | SMALLINT |
Blob | BLOB |
Boolean | SMALLINT |
Byte | SMALLINT |
Char | TEXT |
Clob | TEXT |
Currency | DOUBLE |
Date | DATETIME |
DateTime | DATETIME |
Decimal | DOUBLE |
Double | DOUBLE |
Guid | TEXT |
Int | INT |
NChar | TEXT |
NClob | TEXT |
NVarChar | TEXT |
Single | DOUBLE |
SmallInt | SMALLINT |
TinyInt | SMALLINT |
Time | DATETIME |
TimeStamp | DATETIME |
VarChar | TEXT |
Xml | TEXT |
The national character encoding (NChar, NClob types) in the fields is not supported by SQLite server. However, you can achieve same effect with the Unicode=true connection string parameter.
For more information on dotConnect for SQLite Data Provider please visit the following locations:
Using dotConnect Universal with SQL Client | Using dotConnect Universal with dotConnect for Oracle | Using dotConnect Universal with dotConnect for PostgreSQL | Using dotConnect Universal with dotConnect for MySQL