Sqlite Visual Studio

-->

SQLite / SQL Server Compact Toolbox extension for Visual Studio. This extension adds several features to help your embedded database development efforts: Scripting of tables and data, import from SQL Server and CSV files and much, much more. SQLite, because of its small size (the provider is a mixed-mode assembly that includes the C SQLite database engine), ease of deployment ('Plain old XCopy') and speed, is ideal for small projects - from a demo to even a full website. The full assembly, System.Data.SQLite.DLL, is only 866Kb. This video shows you where to get the SQLite Toolkit, how to install SQLite package in your Visual Studio project as well as the code inside a record into the SQLite database. The code for this video is in the link below. SQLite / SQL Server Compact Toolbox - video demonstrate how to install SQLite database connector for Visual Studio. By default Visu.

A connection string is used to specify how to connect to the database. Connection strings in Microsoft.Data.Sqlitefollow the standard ADO.NET syntax as a semicolon-separated list ofkeywords and values.

Keywords

The following connection string keywords can be used with Microsoft.Data.Sqlite:

Data source

Sqlite

The path to the database file. DataSource (without a space) and Filename are aliases of this keyword.

SQLite treats paths relative to the current working directory. Absolute paths can also be specified.

If empty, SQLite creates a temporary on-disk database that's deleted when the connection is closed.

If :memory:, an in-memory database is used. For more information, see In-Memory databases.

Paths that start with the DataDirectory substitution string are treated the same as relative paths. If set, paths are made relative to the DataDirectory application domain property value.

This keyword also supports URI Filenames.

Mode

The connection mode.

ValueDescription
ReadWriteCreateOpens the database for reading and writing, and creates it if it doesn't exist. This is the default.
ReadWriteOpens the database for reading and writing.
ReadOnlyOpens the database in read-only mode.
MemoryOpens an in-memory database.

Cache

The caching mode used by the connection.

ValueDescription
DefaultUses the default mode of the underlying SQLite library. This is the default.
PrivateEach connection uses a private cache.
SharedConnections share a cache. This mode can change the behavior of transaction and table locking.

Password

The encryption key. When specified, PRAGMA key is sent immediately after opening the connection.

Warning

Password has no effect when encryption isn't supported by the native SQLite library.

Note

The Password keyword was added in version 3.0.

Foreign Keys

A value indicating whether to enable foreign key constraints.

Note

Sqlite

The Foreign Keys keyword was added in version 3.0.

ValueDescription
TrueSends PRAGMA foreign_keys = 1 immediately after opening the connection.
FalseSends PRAGMA foreign_keys = 0 immediately after opening the connection.
(empty)Doesn't send PRAGMA foreign_keys. This is the default.

There's no need enable foreign keys if, like in e_sqlite3, SQLITE_DEFAULT_FOREIGN_KEYS was used to compile the nativeSQLite library.

Recursive triggers

A value that indicates whether to enable recursive triggers.

Note

The Recursive Triggers keyword was added in version 3.0.

ValueDescription
TrueSends PRAGMA recursive_triggers immediately after opening the connection.
FalseDoesn't send PRAGMA recursive_triggers. This is the default.

Connection string builder

You can use SqliteConnectionStringBuilder as a strongly typed way of creating connection strings. It can also be used to prevent connection string injection attacks.

Examples

Basic

A basic connection string with a shared cache for improved concurrency.

Encrypted

An encrypted database.

Visual studio sqlite viewer

Read-only

A read-only database that cannot be modified by the app.

In-memory

A private, in-memory database. New release movies on plex.

Sharable in-memory

Visual Studio Sqlite Viewer

A sharable, in-memory database identified by the name Sharable.

Visual Studio View Sqlite Database

See also