What are the detailed benefits of manipulating SQLite databases in. NET?

Source: Internet
Author: User
Tags sqlite password protection
Summarize:

The library installation of SQLite is very special:

Download Address: Http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki--ok!
Https://www.sqlite.org/download.html. ---downloads for Android, Mac, Linux and other platforms.

To download the installation package:
Sqlite-netfx20-setup-bundle-x64-2005-1.0.108.0.exe---Test ok!
or Sqlite-netfx45-setup-bundle-x64-2012-1.0.108.0.exe need to uninstall version 2.0 before installing. ---test ok!
(in order to be consistent with other software, it is recommended to install the. Net 4.5 version!)

Default installation path: C:\Program files\system.data.sqlite

. NET reference: Just refer to the installation bin directory, System.Data.SQLite.dll a file!

Attention:

1, with bundles of the expression dynamic library is compiled according to the mixed mode, there are pure x86 and pure x64 mode of the library, a total of 3, according to the actual need to choose. (Consistent with project build-target platform!) )

2, download the library, be sure to install, just line!! (reference only, not installed, run will error!!) )

3,. NET uses SQLite, only need to reference System.Data.SQLite.dll, do not have to sqlite3.dll at all. Didn't think of it!

About SQLite:

SQLite is a lightweight database for local data storage. Open source database.

Advantages, it occupies a very low resource, in the embedded device requires hundreds of K of memory is enough, as a lightweight database, he is fast enough to handle, the capacity level of support is T-level, Independent: no additional dependency; open source; support multiple languages.

Detailed Advantages:

1, its design goal is embedded, it occupies a very low resource, in the embedded device, may only need hundreds of K of memory enough.

2, cross-platform and multi-lingual support: It can support Windows/linux/unix and so on mainstream operating system, and can be combined with many programming languages,
such as C, C + +, PHP, Perl, Java, C#,python, Ruby and so on.

3, fast: Compared to MySQL, PostgreSQL two open-source world-renowned database management system, it processing speed faster than they.
(faster than some popular database operations in most ordinary databases.) )

4, support database size to 2TB.

5, small enough, roughly 130,000 lines C code, 4.43M

6. Simple, Easy API

7, source completely open source, you can use for any purpose, including selling it.

8, it also supports transaction processing functions and so on.

Use. NET Operation Sqllite:

Example code 1:

  public string Query () {string DataSource = "E:/tmp/test.db";            System.Data.SQLite.SQLiteConnection.CreateFile (DataSource);            Connection Database System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection ();            System.Data.SQLite.SQLiteConnectionStringBuilder connstr = new System.Data.SQLite.SQLiteConnectionStringBuilder (); ConnStr.            DataSource = DataSource; ConnStr. Password = "admin";//Set password, SQLite ADO. NET implements the database password protection Conn. ConnectionString = ConnStr.            ToString (); Conn.            Open ();            CREATE TABLE System.Data.SQLite.SQLiteCommand cmd = new System.Data.SQLite.SQLiteCommand ();            String sql = "CREATE TABLE Test (username varchar (), password varchar (20))";            Cmd.commandtext = SQL; Cmd.            Connection = conn; Cmd.            ExecuteNonQuery ();            Insert Data sql = "INSERT INTO Test VALUES (' A ', ' B ')";           Cmd.commandtext = SQL; Cmd.            ExecuteNonQuery ();            Take out Data sql = "SELECT * from Test";            Cmd.commandtext = SQL; System.Data.SQLite.SQLiteDataReader reader = cmd.            ExecuteReader ();            StringBuilder sb = new StringBuilder (); while (reader. Read ()) {sb. Append ("Username:"). Append (reader. GetString (0)). Append ("\ n"). Append ("Password:"). Append (reader.            GetString (1)); }//messagebox.show (sb.)            ToString ()); Return SB.        ToString (); }

Sample Code 2: Transactional Operations:

using (sqliteconnection conn = new Sqliteconnection (connectionString)) { Conn.                Open ();                Sqlitecommand cmd = new Sqlitecommand (); Cmd.                Connection = conn; Sqlitetransaction TX = conn.                BeginTransaction (); Cmd.                Transaction = TX;                        try {for (int n = 0; n < sqlstringlist.count; n++) { String strSQL = Sqlstringlist[n].                        ToString (); if (strSQL. Trim ().                            Length > 1) {cmd.commandtext = strSQL; Cmd.                        ExecuteNonQuery ();                }} tx.commit (); } catch (System.Data.SQLite.SQLiteException E) {tx.                    Rollback ();                throw new Exception (e.message); }

Related articles:

The use of SQLite relational database

How to be in. NET using the MySQL database

Related videos:

SQLite Advanced Courses

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.