System. Data. Sqlite Getting Started Guide

Source: Internet
Author: User

Start with System. Data. Sqlite...
First import/using:

Code
  1. Using System. Data. SQLite;

Connection and Command:

Code
  1. Private SQLiteConnection conn;
  2. Private SQLiteCommand cmd;

Connect to db:

Code
  1. Conn = new SQLiteConnection ("Data Source = c: \ test. db ");
  2. Conn. Open ();

INSERT/UPDATE:

 

Code
  1. Cmd = conn. CreateCommand ();
  2. Cmd. CommandText = "insert into user (email, name) VALUES ('email ', 'name ')";
  3. Cmd. ExecuteNonQuery ();
  4. Cmd. CommandText = "UPDATE userSET name = 'codelicious 'where id = 1 ";
  5. Cmd. ExecuteNonQuery ();

SELECT:

 

Code
  1. Cmd. CommandText = "select id, name FROM user ";
  2. SQLiteDataReader reader = cmd. ExecuteReader ();
  3. If (reader. HasRows)
  4. {
  5. While (reader. Read ())
  6. {
  7. Console. WriteLine ("ID:" + reader. GetInt16 (0 ));
  8. Console. WriteLine ("name:" + reader. GetString (1 ));
  9. }
  10. }

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.