Methods for using SQLite database in asp.net-practical tips

Source: Internet
Author: User
Tags connection pooling datetime odbc rollback sqlite sqlite database create database
In practice, when I use Sqliteadmin and SQLite Expert Professional 2 software to create a new SQLite database in the asp.net is not used, always error: File is not a legitimate database. Later, a method is used to create a new database directly inside the asp.net using a referenced DLL.

String datasource = "D:\\test.db"; The address of the database file

System.Data.SQLite.SQLiteConnection.CreateFile (DataSource); Generate file

The resulting test.db can be used in asp.net, when you use Sqliteadmin and SQLite Expert Professional 2 software to open it in the inside of the table does not affect its use.

The operation of SQLite is very similar to access, but the beginning of OLE DB has become SQLite ...

. NET Framework Data Provider for ODBC

driver=SQLite3 ODBC DRIVER; database=mydb.db; longnames=0; timeout=1000; notxn=0;  Syncpragma=NORMAL; stepapi=0;
This is just one connection string sample for the wrapping OdbcConnection class that calls the underlying ODBC Driver. respective ODBC driver for the more connection strings to use with this class.

SQLite3 ODBC Driver

driver=SQLite3 ODBC DRIVER; database=mydb.db; longnames=0; timeout=1000; notxn=0;  Syncpragma=NORMAL; stepapi=0;

Sqlite.net

Basic (fundamental)
Data source=filename; version=3;
Using UTF16 (using UTF16 encoding)
Data source=filename; version=3; useutf16encoding=True;
With password (password)
Data source=filename; version=3; password=mypassword;
Using the Pre 3.3x database format (use 3.3x Pre-database format)
Data source=filename; version=3; Legacy format=True;
Read Only connection (read-only connection)
Data source=filename; version=3; Read only=True;
With connection pooling (set connection pool)
Data source=filename; version=3; pooling=False; Max Pool size=;
Using datetime.ticks as DateTime format ()
Data source=filename; version=3; datetimeformat=Ticks;
The default value is ISO8601 which activates the use of the ISO8601 datetime format
Store GUID as text (the GUID is stored as a literal and the default is binary)
Data source=filename; version=3; Binaryguid=False;
If you need more storage for the GUID as a text store
Specify cache size (Specify cache sizes)
Data source=filename; version=3; Cache size=2000;
Cache Size Unit is byte
Specify page size (Specify page sizes)
Data source=filename; version=3; Page size=1024;
Page Size Unit is byte
Disable Enlistment in distributed transactions
Data source=filename; version=3; enlist=N;
Disable Create Database behaviour (disable the creation of databases behavior)
Data source=filename; version=3; failifmissing=True;
By default, if the database file does not exist, a new one is created automatically, using this parameter, will not be created, but thrown exception information
Limit the size of database ( Limit Database Size )
Data source=filename; version=3; Max Page count=5000;
The Max Page Count is measured in the pages. This parameter limits the maximum number of pages of the database.
Disable the Journal File ( disable log rollback )
Data source=filename; version=3; Journal mode= off;
This one disables the rollback journal entirely.
Persist the Journal File (persistent)
Data source=filename; version=3; Journal mode=Persist;
This one blanks and leaves the journal file on disk after a commit. The Default behaviour is to delete the Journal File for each commit.
controling file Flushing
Data source=filename; version=3; synchronous= full;
      full specifies a full flush to take action after each write. Normal is the default value. Off means the underlying OS flushes I/O ' s.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.