C#簡單訪問SQLite資料庫的方法(安裝,串連,查詢等)_C#教程

來源:互聯網
上載者:User

本文執行個體講述了C#簡單訪問SQLite資料庫的方法。分享給大家供大家參考,具體如下:

下載最新版SQLite(http://www.sqlite.org/download.html),其他版本也可以,這裡使用的版本是sqlite-3_6_6_1

a.解壓後copy c:\sqlite-3_6_6_1

b.進入cmd模式,進入sqlite-3_6_6_1目錄,執行sqlite3 mytest.db

c.

create table test (seq int,desc varchar(8));insert into mytable1 values (1,'item');

資料建立完成

2.下載System.Data.SQLite(http://sqlite.phxsoftware.com/),安裝,安裝后里面會有詳細的DEMO和文檔。請詳細查看。

3.將mytest.db複製到Bin/Debug目錄下。

4.開啟VS2005,參考System.Data.SQLite安裝目錄下的System.Data.SQLite.DLL

using System.Data.SQLite;SQLiteConnection cnn = new SQLiteConnection();cnn.ConnectionString = @"Data Source=mytest.db;Pooling=true;FailIfMissing=false"cnn.Open();SQLiteCommand cmd = new SQLiteCommand();cmd.Connection = cnn;cmd.CommandText = "SELECT * FROM test";SQLiteDataAdapter da = new SQLiteDataAdapter();da.SelectCommand = cmd;DataSet ds = new DataSet();da.Fill(ds);// 分頁查詢顯示語句Select * From test Limit 10 Offset 10;

以上語句表示從Account表擷取資料,跳過10行,取10行

更多關於C#相關內容感興趣的讀者可查看本站專題:《C#程式設計之線程提示總結》、《C#操作Excel技巧總結》、《C#中XML檔案操作技巧匯總》、《C#常見控制項用法教程》、《WinForm控制項用法總結》、《C#資料結構與演算法教程》、《C#數組操作技巧總結》及《C#物件導向程式設計入門教程》

希望本文所述對大家C#程式設計有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.