The use of -58-sqlite

Source: Internet
Author: User
Tags sqlite

Description: Document-type relational database, more for mobile

1.1 Adding references

' 1.1.1 System.Data.SQLite.xml

1.1.2 System.Data.SQLite.dll

1.2 Settings for connection strings

string connstr = @ "Data source=f:\users\home\documents\visual Studio 2013\paodingjieniu\pdjn.db;version=3;";

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Data.SQLite;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespacefuxi{ Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); }        Private voidForm1_Load (Objectsender, EventArgs e) {            //00 constructing a collection of dataList<managerinfo> ListManager =NewList<managerinfo>( ); //01-Show Data//01-01 Connection string "physical path; version number":            stringConnStr =@"data source=f:\users\home\documents\visual Studio 2013\paodingjieniu\pdjn.db;version=3;"; //01-02 Creating a connection string            using(Sqliteconnection conn =Newsqliteconnection (CONNSTR)) {                //01-03 Query StatementsSqlitecommand cmd =NewSqlitecommand ("SELECT * from Managerinfo", conn); //01-04 Execute CommandConn.                Open (); Sqlitedatareader Reader=cmd.                ExecuteReader (); if(reader. HasRows) { while(reader. Read ()) {Listmanager.add (NewManagerinfo () {Mid= Convert.ToInt32 (reader["Mid"]), Mname= reader["Mname"]. ToString (), Mpwd= reader["mpwd"]. ToString (), Mtype=convert.toint32 (reader["Mtype"])                        }); }                 }                //02 Display on DataGridViewDatagridview1.datasource =ListManager; }        }    }}
code Example
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespacefuxi{ Public Partial classManagerinfo { Public intMid {Get;Set; }  Public stringMname {Get;Set; }  Public stringmpwd {Get;Set; }  Public intMtype {Get;Set; } }}
Managerinfo

The use of -58-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.