ADO.NET 2.0 SQLite Data Provider
Version 1.0.6 - Mar 1, 2005
Written by Robert Simpson (firstname.lastname@example.org)
Released to the public domain, use at your own risk!
This provider was written and verified using the Visual Studio 2005 November and
The latest version can be downloaded here
In order to use the SQLiteFactory and have the SQLite data provider enumerated in
the DbProviderFactories methods, you must add the following segment into either
your application's app.config or the system's machine.config located in the %SystemRoot%\Microsoft.Net\Framework\v2.xxxx\Config
- DbProviderFactory support, just add the XML below at the machine.config and/or app.config level.
- Full support for ATTACH'ed databases. Exposed as Catalogs in the
schema. When cloning a connection, all attached databases are automatically
re-attached to the new connection.
- DbConnection.GetSchema(...) support includes the MetaDataCollections,
DataSourceInformation, Columns, Tables, Views, Catalogs
and Indexes keywords.
- Enhanced DbDataReader.GetSchemaTable() functionality returns catalog, namespace
and detailed schema information even for complex queries.
- Named and unnamed parameters.
- Full UTF-8 and UTF-16 support.
- Multiple simultaneous DataReaders (one DataReader per Command however).
- Full support for user-defined scalar and aggregate functions, encapsulated into
easy-to-use base class in which only a couple of overrides are necessary to implement
new SQL functions.
- Full support for user-defined collating sequences, every bit as simple to implement
as user-defined functions and uses the same base class.
<add name="SQLite Data Provider" invariant="System.Data.SQLite" support="3F" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
Development Notes Regarding the SQLite 3 Source Code
*** At this time, the necessary changes to the DLL to support Windows CE have
not been completed. All function calls that return or pass a 64-bit value
have been wrapped, but the necessary OS changes have not been finished.
Steps for merging the sqlite3 core codebase:
- Download the latest sqlite3 source from
- Extract the source code to the SQLite.Interop\src directory of this project
- Open the src\select.c file.
- Add #include "../interop.h" to the top of the file where the other include's
- Scroll down the select.c file to around line 748. Change the name of the function static void generateColumnNames to
static void _generateColumnNames (note the underscore in front of the name).
- Compile it.
1.06 - Mar 1, 2005
- Speed-ups to SQLiteDataReader. It was interop'ing every time it tried to
fetch a field due to a logic error.
- Changed/Added some code to SQLiteConvert's internal DbType, Type and TypeAffinity
- Fixed the SQLiteDataReader to obey the flags set in the optional CommandBehavior
flag from SQLiteCommand.ExecuteReader().
- Changed the default page size to 1024 to reflect the defaults of
SQLite. Ignores the "Page Size" connection string option for
memory databases, as tests revealed that changing it resulted in memory
- Performance enhancements to the SQLiteCommand and SQLiteStatement classes which
reduced the 100,000 row insert execution time as well as the various Function execution
1.05 - Feb 25, 2005
- Fixed the SQLite3 C# class step/reset functions to accomodate schema changes
that invalidate a prepared statement. Statements are recompiled transparently.
- Moved all native DLL declarations to an UnsafeNativeMethods class.
- Split several classes into their own modules for readability.
- Renamed many internal variables, reviewed access to variables marked as internal
and altered their protection levels accordingly.
- Due to the presence of the altered sqlite3 codebase and so many added interop
functions, I decided to rename the sqlite3 C project and the DLL to SQLite.Interop.DLL.
This is the same core sqlite3 codebase but designed specifically for this
ADO.NET provider. This eliminates any possibility of someone dropping another
build of sqlite3.dll into the system and rendering the provider inoperable.
In the future if the folks at sqlite.org finally introduce a method of retrieving
column usage for an arbitrary prepared statement, I'll retool this library to be
a lightweight function call wrapper around the core binary distribution.
- Added [SuppressUnmanagedCodeSecurity] attribute to the UnsafeNativeMethods class
which brings VS2005 November CTP execution speeds inline with the December CTP.
- Added a bin directory to the project root where pre-compiled
binaries can be found.
- Added a doc directory where preliminary documentation on the
class library can be found.
- Documented a lot more of the classes internally.
1.04 - Feb 24, 2005
1.03 - Feb 23, 2005
- Removed the SQLiteContext class and revamped the way UserFunctions work to simplify
- Fixed a counting bug in the TestCases class, specifically in the function tests
where I wasn't resetting the counter and it was consequently reporting intrinsic
and raw select calls as being much much faster than they actually were. The
numbers are now much closer to what I expected for performance, with .NET user-functions
still being the slowest, but only by a small margin.
- Small performance tweaks to SQLiteDataReader.
- Added PageSize to the SQLiteConnectionStringBuilder and subsequently to the SQLiteConnection
- Added a PRAGMA encoding=XXX execution statement to the SQLiteConnection after
opening a connection.
- Fixed up SQLiteCommandBuilder to correct implementation errors, which resulted
in an enormous performance boost in the InsertMany test. 10,000 row
insert that executed in 1500ms now executes in 500ms.
- Fixed several errors in the SQLite3_UTF16 class. ToString() was working
incorrectly and the Open() method failed to register user defined functions and
- Fixed a bug in SQLiteCommand.ClearCommands() whereby only the first statement
was being properly cleaned up.
- Fixed a bug in SQLiteDataReader whereby calling NextResult() would not properly
reset the previously-executed command in the sequence.
- Added an InsertManyWithIdentityFetch test, which appends a select clause to populate
the ID of the last inserted row into the InsertCommand, demonstrating ADO.NET's
ability to auto-fetch identity columns on insert.
1.02 - Feb 21, 2005
- Tweaks to the xxx_interop functions that return char *'s, so they also return
the length. Saves an interop call to get the UTF-8 string length during conversion
to a .NET string.
- Reworked the whole interop.c thing into interop.h and reduced the code required
to merge the main sqlite3 codebase.
- Added support for user-defined collations.