C#操作Sqlite快速入门及相关工具收集
Sqlite不需要安裝即可使用。
Sqlite是不是那個System.Data.SQLite.DLL臨時創(chuàng)建了數(shù)據(jù)庫引擎?
1.新建一個WinForm項目,引用System.Data.SQLite.DLL.界面如下
1.1??SQLiteConnection.CreateFile(“D:/Data.db3”);
這樣就可以創(chuàng)建一個數(shù)據(jù)庫文件,名稱隨意。
封裝成一個函數(shù)
?
1.2? 數(shù)據(jù)庫連接字符串
string?connStr?=?@"Data?Source="?+?System.Environment.CurrentDirectory?+?@"\HyData\HyData.db3;Initial?Catalog=sqlite;Integrated?Security=True;Max?Pool?Size=10";這里新建了一個HyData目錄存放數(shù)據(jù)庫。
1.3? 執(zhí)行Sql語句
//執(zhí)行查詢 //ExecQuery("select * from HyTest"); private void ExecQuery(string sqlStr) {using (DbConnection conn = new SQLiteConnection(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());}}} }//執(zhí)行查詢返回DataSet private DataSet ExecDataSet(string sqlStr) {using (SQLiteConnection conn = new SQLiteConnection(connStr)){conn.Open();SQLiteCommand cmd = conn.CreateCommand();cmd.CommandText = sqlStr;cmd.CommandType = CommandType.Text;SQLiteDataAdapter da = new SQLiteDataAdapter(cmd);DataSet ds = new DataSet();da.Fill(ds);return ds;} }
?
?本文示例項目源碼:HySqlite.rar?http://revit.5d6d.net/thread-799-1-1.html
2.Sqlite相關(guān)工具
2.1? Sqlite數(shù)據(jù)庫可以到www.sqlite.org下載,非常小
或sqlite-shell-win32-x86-3070600.zip
http://revit.5d6d.net/thread-800-1-1.html
2.2? C#操作Sqlite的官方示例代碼,一時忘了url
或http://revit.5d6d.net/thread-801-1-1.html包括
SQLite-1.0.66.0-source.zip
SQLite-1.0.66.0-binaries.zip
debug.rar
2.3? Sqlite兩個界面工具
SQLiteExpertSetup.exe
http://revit.5d6d.net/thread-802-1-1.html這個比較好用,破解版
SQLite Database Browser.exe
http://revit.5d6d.net/thread-803-1-1.html這個據(jù)說用在手機上
2.4? 小巧的界面工具SqliteSpy(感謝http://www.cnblogs.com/qq419524837/提供)
下載:SQLiteSpy?或http://revit.5d6d.net/thread-808-1-1.html
轉(zhuǎn)載于:https://www.cnblogs.com/lgx5/p/9241632.html
總結(jié)
以上是生活随笔為你收集整理的C#操作Sqlite快速入门及相关工具收集的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: webpack结合reactjs、vue
- 下一篇: .NET(C#、VB)移动开发——Smo