C # simple access to SQLite database methods (installation, connection, query, etc.) _c# tutorial

Source: Internet
Author: User
Tags sqlite sqlite database

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.

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.