Continue: Use SQLite in C #

Source: Internet
Author: User

* Downloaded http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki from sqlite-netFx35-setup-bundle-x86-2008-1.0.83.0.exe
* Install vs2008. During the installation process, some errors are prompted on the console interface, and the installation is complete.
* Create a new C # project in vs2008, "Add references..." browse to the sqlite-netFx35-setup-bundle-x86-2008-1.0.83.0.exe installation directory
* For example, my installation directory: D: \ Program Files \ system. Data. SQLite \ 2008 \ bin
* Select system. Data. SQLite. dll. In the project references, you can see that there is one more: system. Data. SQLite.
* Add using system. Data. SQLite in form1.cs of the project;
* AddedCodeAs follows:

* After the compilation and debugging are passed, the cause of the problem is that the csdner's. Net version is incorrect, resulting in a pass-through test the day before yesterday.

Using system. data. SQLite; namespace testusesqlite {public partial class form1: FORM {private string datasource = "contactbookdb. SQLite "; Public form1 () {initializecomponent (); sqliteconnection. createfile (datasource); sqliteconnection dbconn = new sqliteconnection ("Data Source =" + datasource); dbconn. open (); sqlitecommand dbcmd = dbconn. createcommand (); dbcmd. commandtext = "create table telephonebook (personid varchar (20), telephone varchar (30), type varchar (20)"; dbcmd. executenonquery (); dbcmd. commandtext = "insert into telephonebook values ('mtb', '000000', 'not mobile')"; dbcmd. executenonquery (); dbcmd. commandtext = "select * From telephonebook"; sqlitedatareader datareader = dbcmd. executereader (); datatable = new datatable (); If (datareader. hasrows) {datatable. load (datareader);} datagridview1.datasource = datatable; datareader. close (); dbconn. close ();}}}
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.