This article illustrates a simple way for C # to access a SQLite database. Share to everyone for your reference, specific as follows:
Download the latest version of SQLite (http://www.sqlite.org/download.html), other versions are also available, the version used here is Sqlite-3_6_6_1
A. After decompression copy C:\sqlite-3_6_6_1
B. Enter cmd mode, enter Sqlite-3_6_6_1 directory, execute sqlite3 mytest.db
C.
CREATE TABLE Test (SEQ int,desc varchar (8));
INSERT into mytable1 values (1, ' item ');
Data Establishment completed
2. Download System.Data.SQLite (http://sqlite.phxsoftware.com/), installation, after the installation will have detailed demo and documentation. Please look at it in detail.
3. Copy the mytest.db to the Bin/debug directory.
4. Open VS2005, refer to System.Data.SQLite.DLL under System.Data.SQLite installation directory
Using System.Data.SQLite;
Sqliteconnection cnn = new Sqliteconnection ();
Cnn. ConnectionString = @ "Data source=mytest.db; Pooling=true; Failifmissing=false "
CNN. Open ();
Sqlitecommand cmd = new Sqlitecommand ();
Cmd. Connection = CNN;
Cmd.commandtext = "SELECT * from Test";
Sqlitedataadapter da = new Sqlitedataadapter ();
Da. SelectCommand = cmd;
DataSet ds = new DataSet ();
Da. Fill (DS);
Paging query Display Statement
Select * from Test Limit 10;
The above statement represents fetching data from the account table, skipping 10 rows, and taking 10 rows
Read more about C # Interested readers can view the site topics: "C # Programming Thread Usage Tips summary", "C # Operation Excel Skills Summary", "C # XML file Operation Tips Summary", "C # Common control usage Tutorial", "WinForm Control Usage Summary", "C # tutorial on data structure and algorithms, summary of C # array manipulation techniques, and an introductory course on C # object-oriented programming
I hope this article will help you with C # programming.