C # Operations SQLite Quick Start and related tools collection

Source: Internet
Author: User
Tags rar sqlite sqlite database

SQLite does not need to be installed to use.
SQLite is not that System.Data.SQLite.DLL temporarily created the database engine?

1. Create a new WinForm project with reference to System.Data.SQLite.DLL. The interface is as follows

1.1 Sqliteconnection.createfile ("D:/DATA.DB3");
This allows you to create a database file with a name that is arbitrary.
Encapsulated as a function

Create a database file that is saved under the current directory under the Hydata folder//createdb ("Hydata.db3");p rivate void Createdb (String dbName) {    string DatabaseFileName = System.Environment.CurrentDirectory + @ "/hydata/" + dbName;    Sqliteconnection.createfile (databasefilename);}

1.2 Database connection string

string connstr = @ "Data source=" + System.Environment.CurrentDirectory + @ "\hydata\hydata.db3;initial catalog=sqlite;i Ntegrated security=true; Max Pool size=10 ";

A new Hydata directory database is created here.

1.3 Execute SQL statement

Execute SQL statement//Create a table:  executesql ("CREATE Table Hytest (TestID TEXT)");//Insert some data:  ExecuteSQL ("INSERT INTO hytest ( TestID) VALUES (' 1001 ') ");p rivate void ExecuteSQL (String sqlstr) {    using (DbConnection conn = new Sqliteconnection ( CONNSTR))    {        Conn. Open ();        DbCommand COMM = conn. CreateCommand ();        Comm.commandtext = sqlstr;        Comm.commandtype = CommandType.Text;        Comm. ExecuteNonQuery ();    }}

  

//Execute Query//ExecQuery ("SELECT * from Hytest");Private voidExecQuery (stringsqlstr) {    using(DbConnection conn =Newsqliteconnection (CONNSTR)) {Conn.        Open (); DbCommand Comm=Conn.        CreateCommand (); Comm.commandtext=sqlstr; Comm.commandtype=CommandType.Text; using(IDataReader reader =Comm. ExecuteReader ()) { while(reader. Read ()) {MessageBox.Show (reader[0].            ToString ()); }        }    }}//execute a query to return a datasetPrivateDataSet Execdataset (stringsqlstr) {    using(Sqliteconnection conn =Newsqliteconnection (CONNSTR)) {Conn.        Open (); Sqlitecommand cmd=Conn.        CreateCommand (); Cmd.commandtext=sqlstr; Cmd.commandtype=CommandType.Text; Sqlitedataadapter da=Newsqlitedataadapter (CMD); DataSet DS=NewDataSet (); Da.        Fill (DS); returnds; }}

This sample project Source: Hysqlite.rar http://revit.5d6d.net/thread-799-1-1.html

2.Sqlite Related Tools

2.1 SQLite database can be downloaded to www.sqlite.org , very small
or Sqlite-shell-win32-x86-3070600.zip
Http://revit.5d6d.net/thread-800-1-1.html

2.2 C # Operation SQLite's official sample code, forgetting the URL for a moment
or http://revit.5d6d.net/thread-801-1-1.html include
Sqlite-1.0.66.0-source.zip
Sqlite-1.0.66.0-binaries.zip
Debug.rar

2.3 SQLite Two interface tools

SQLiteExpertSetup.exe
Http://revit.5d6d.net/thread-802-1-1.html this more useful, cracked version
SQLite Database Browser.exe
Http://revit.5d6d.net/thread-803-1-1.html This is supposed to be on the phone.

2.4 Small Interface Tool Sqlitespy (thanks to http://www.cnblogs.com/qq419524837/)

Download: Sqlitespy or http://revit.5d6d.net/thread-808-1-1.html

C # Operations SQLite Quick Start and related tools collection

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.