. Net uses sqllite instances

Source: Internet
Author: User
SQLite Introduction
The official website of SQLite is: http://www.sqlite.org /. SQLite is a small C-function library that implements a complete (self-contained), embedded (embeddable), and zero-configuration SQL database engine. It is completely free. For more information, see the official website.

Management tools
Many related management tools. SQLite Administrator is recommended.

Use in. Net
Go to the http://sqlite.phxsoftware.com/download ADO. NET 2.0 Provider for SQLite. Download binaries zip. After downloading and decompress the package, you can find System. Data. SQLite. DLL in the bin directory. Use the Add Refrence function in vs2008 to Add System. Data. SQLite. DLL to the project. Run the following code:

String datasource = "e:/tmp/test. db ";
System. Data. SQLite. SQLiteConnection. CreateFile (datasource );
// Connect to the 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 the Password. SQLite ADO. NET implements database Password protection.
Conn. ConnectionString = connstr. ToString ();
Conn. Open ();
// Create a table
System. Data. SQLite. SQLiteCommand cmd = new System. Data. SQLite. SQLiteCommand ();
String SQL = "CREATE TABLE test (username varchar (20), 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 ();
// Retrieve 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 ());

See: www.cnblogs.com/ysxlh/archive/2008/10/11/1308794.html

Http://www.infoq.com/cn/news/2008/01/sqlite-in-three-minutes

I have been looking for an alternative to access. SQL anywhere and interbase are not very easy to use. There is also a berkely DB that does not support SQL statements.

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.