How to introduce SQLite linq2db in vs2012 and 2013, and the basics of C # operations for SQLite.

Source: Internet
Author: User
Tags sqlite

After you create a new project, in the Package management console, enter:


Install-package linq2db. Sqlite


Enter.


In the previous Turn & wall installed (by the way GFW: I xxx! ), this installation is installed from the local cache.



After the installation is successful, look at the following changes to the project in the solution:



Instant finish is the sense of sight! Have you got any wood?





Finally on the C # operation SQLite example, yesterday just researched out, fresh Oh!

Using system;using system.io;using system.collections.generic;using system.linq;using System.Text;using System.threading.tasks;using System.data.sqlite;namespace consoleapplication1{class Program {static void Ma            In (string[] args) {using (sqliteconnection conn = new Sqliteconnection ("Data source=d:\\abc.db")) {Conn.                Open ();                Droptable (conn);                CreateTable (conn);                INSERTDATA (conn);                GETDATA (conn); Conn.            Close (); }} private static void CreateTable (Sqliteconnection conn) {Sqlitecommand cmd = c Onn.            CreateCommand (); Cmd. CommandText = @ "CREATE TABLE Question (ID Integer primary key, Que            Stioncontent text, htmlcontent text) "; Cmd.        ExecuteNonQuery (); } private static void InsertData (Sqliteconnection conn) {Sqlitecommand cmd = conn.            CreateCommand ();            StringBuilder sb = new StringBuilder (); for (int i = 0; i <; i++) {sb.                    AppendFormat ("INSERT into Question (id,questioncontent,htmlcontent) VALUES ({0}, ' question content: {1} ', ' Question answer {2} ');", I, Guid.NewGuid (). ToString (), Guid.NewGuid ().            ToString ()); } Cmd.commandtext = sb.            ToString (); Cmd.        ExecuteNonQuery (); } private static void GetData (Sqliteconnection conn) {Sqlitecommand cmd = conn.            CreateCommand ();            Cmd.commandtext = "SELECT * from Question"; Sqlitedatareader reader = cmd.            ExecuteReader (); while (reader. Read ()) {var obj = new {Id = reader. GetInt32 (0), questioncontent = reader. GetString (1), htmlcontent = reader.                GetString (2)}; Console.WriteLine (String. Format ("id:{0}; Questioncontent={1}; Htmlcontent={2} ", obj. Id, obj. QuestionContent, obj.            Htmlcontent)); }} private static void Droptable (Sqliteconnection conn) {Sqlitecommand cmd = conn.            CreateCommand ();            Cmd.commandtext = "Drop Table Question"; Cmd.        ExecuteNonQuery (); }    }}


Finally thanks to the IT person: http://blog.csdn.net/dyllove98/article/details/9674137, I basically copied this blog, and then removed the back of the template part of the temporary.



How to introduce SQLite linq2db in vs2012 and 2013, and the basics of C # operations for SQLite.

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.