C # access the SQLite Database

Source: Internet
Author: User

1. download the latest version of SQLite (http://www.sqlite.org/download.html), other versions can also.

A. Copy C:/sqlite-3_5-0 after decompression

B. Enter cmd mode, enter the sqlite-3_5_0 directory, and execute sqlite3 mytest. DB

C. Create Table mytable1 (SEQ int, DESC varchar (8); insert into mytable1 values (1, 'project'); Data creation complete

2. Download System. Data. SQLite (http://sqlite.phxsoftware.com/), install

3. Open vs2005 and refer to system. Data. SQLite. dll in the installation directory of system. Data. SQLite.

Sqliteconnection CNN =   New Sqliteconnection ();
CNN. connectionstring =   @" Data Source = C: sqlite-3_5_0mytest.db " ;
CNN. open ();

Sqlitecommand cmd =   New Sqlitecommand ();
Cmd. Connection = CNN;
Cmd. commandtext =   " Select * From mytable1 " ;
Sqlitedataadapter da =   New Sqlitedataadapter ();
Da. selectcommand = CMD;
Dataset DS =   New Dataset ();
Da. Fill (DS );

 

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.