資源簡介
自己寫的SQLite數據操作的簡單例子。
有Datagridview,treeView和listView三個作為顯示數據。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Data.SQLite;
using?System.Data;
using?System.Configuration;
namespace?SQLiteHelper
{
????public?class?SQLiteHelper
????{
????????#region?SQlite數據操作
????????///?
????????///?執行SQl語句?返回執行的行數
????????///?
????????///?鏈接數據庫的字符串
????????///?sql執行語句
????????///?參數
????????public?static?int?SQLiteCommand(string?str?string?SqlString?params?SQLiteParameter[]?Param)
????????{
????????????try
????????????{
????????????????SQLiteConnection?slcn?=?new?SQLiteConnection(str);
????????????????SQLiteCommand?slcmd?=?slcn.CreateCommand();
????????????????PrepareCommand(slcmd?slcn?null?SqlString?Param);
????????????????return?slcmd.ExecuteNonQuery();
????????????}
????????????catch?(System.Data.SQLite.SQLiteException?ex)
????????????{
????????????????throw?new?Exception(ex.Message);
????????????}
????????}
????????///?
????????///?執行SQl語句?返回DataSet
????????///?
????????///?鏈接數據庫的字符串
????????///?sql執行語句
????????///?參數
????????///?DataSet
????????public?static?DataSet?SQLiteCommandDataSet(string?str?string?SqlString?params?SQLiteParameter[]?Param)
????????{
????????????try
????????????{
????????????????DataSet?ds?=?new?DataSet();
????????????????SQLiteConnection?slcn?=?new?SQLiteConnection(str);
????????????????SQLiteCommand?slcmd?=?slcn.CreateCommand();
????????????????PrepareCommand(slcmd?slcn?null?SqlString?Param);
????????????????SQLiteDataAdapter?sda?=?new?SQLiteDataAdapter(slcmd);
????????????????slcmd.Parameters.Clear();
????????????????sda.Fill(ds);
????????????????sda.Dispose();
????????????????return?ds;
????????????}
????????????catch?(System.Data.SQLite.SQLiteException?ex)
????????????{
????????????????throw?new?Exception(ex.Message);
????????????}
????????}
????????///?
????????///?執行SQl語句?返回數據集SQLiteDataReader
????????///?
????????///?鏈接數據庫的字符串
????????///?sql執行語句
????????///?參數
????????///?SQLiteDataReader
????????public?static?SQLiteDataReader?SQLiteCommandDataReader(string?str?string?SqlString?params?SQLiteParameter[]?Param)
????????{
????????????try
????????????{
????????????????SQLiteConnection?slcn?=?new?SQLiteConnection(str);
????????????????SQLiteCommand?slcmd?=?slcn.CreateCommand();
????????????????PrepareCommand(slcmd?slcn?null?SqlString?Param);
????????????????SQLiteDataReader?myReader?=?slcmd.ExecuteReader();
????????????????slcmd.Parameters.Clear();
????????????????return?myReader;
????????????}
????????????catch?(System.Data.SQLite.SQLiteException?ex)
????????????{
????????????????throw?new?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????5632??2011-11-27?20:21??TestSQLiteFunction\SQLiteHelper\bin\Debug\SQLiteHelper.dll
?????文件??????13824??2011-11-27?20:21??TestSQLiteFunction\SQLiteHelper\bin\Debug\SQLiteHelper.pdb
?????文件?????839680??2008-10-02?09:02??TestSQLiteFunction\SQLiteHelper\bin\Debug\System.Data.SQLite.DLL
?????文件???????5930??2011-11-27?20:21??TestSQLiteFunction\SQLiteHelper\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件???????4811??2011-11-27?16:39??TestSQLiteFunction\SQLiteHelper\obj\Debug\ResolveAssemblyReference.cache
?????文件????????662??2011-11-27?17:06??TestSQLiteFunction\SQLiteHelper\obj\Debug\SQLiteHelper.csproj.FileListAbsolute.txt
?????文件???????5632??2011-11-27?20:21??TestSQLiteFunction\SQLiteHelper\obj\Debug\SQLiteHelper.dll
?????文件??????13824??2011-11-27?20:21??TestSQLiteFunction\SQLiteHelper\obj\Debug\SQLiteHelper.pdb
?????文件???????1380??2011-11-27?15:49??TestSQLiteFunction\SQLiteHelper\Properties\AssemblyInfo.cs
?????文件???????4221??2011-11-27?20:19??TestSQLiteFunction\SQLiteHelper\SQLiteHelper.cs
?????文件???????2425??2011-11-27?16:39??TestSQLiteFunction\SQLiteHelper\SQLiteHelper.csproj
?????文件??????14336??2011-11-27?21:01??TestSQLiteFunction\TestSQLiteFunction\bin\Debug\library.db
?????文件???????5632??2011-11-27?20:21??TestSQLiteFunction\TestSQLiteFunction\bin\Debug\SQLiteHelper.dll
?????文件??????13824??2011-11-27?20:21??TestSQLiteFunction\TestSQLiteFunction\bin\Debug\SQLiteHelper.pdb
?????文件?????839680??2008-10-02?09:02??TestSQLiteFunction\TestSQLiteFunction\bin\Debug\System.Data.SQLite.DLL
?????文件??????11776??2011-11-27?20:53??TestSQLiteFunction\TestSQLiteFunction\bin\Debug\TestSQLiteFunction.exe
?????文件??????28160??2011-11-27?20:53??TestSQLiteFunction\TestSQLiteFunction\bin\Debug\TestSQLiteFunction.pdb
?????文件??????11608??2011-11-27?20:55??TestSQLiteFunction\TestSQLiteFunction\bin\Debug\TestSQLiteFunction.vshost.exe
?????文件????????490??2010-03-17?22:39??TestSQLiteFunction\TestSQLiteFunction\bin\Debug\TestSQLiteFunction.vshost.exe.manifest
?????文件???????3283??2011-11-27?20:53??TestSQLiteFunction\TestSQLiteFunction\Form1.cs
?????文件???????5999??2011-11-27?20:53??TestSQLiteFunction\TestSQLiteFunction\Form1.Designer.cs
?????文件???????5817??2011-11-27?20:53??TestSQLiteFunction\TestSQLiteFunction\Form1.resx
?????文件???????6395??2011-11-27?20:53??TestSQLiteFunction\TestSQLiteFunction\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????566??2011-11-27?20:53??TestSQLiteFunction\TestSQLiteFunction\obj\x86\Debug\GenerateResource-ResGen.read.1.tlog
?????文件????????958??2011-11-27?20:53??TestSQLiteFunction\TestSQLiteFunction\obj\x86\Debug\GenerateResource-ResGen.write.1.tlog
?????文件???????7903??2011-11-27?20:21??TestSQLiteFunction\TestSQLiteFunction\obj\x86\Debug\ResolveAssemblyReference.cache
?????文件???????1518??2011-11-27?20:55??TestSQLiteFunction\TestSQLiteFunction\obj\x86\Debug\TestSQLiteFunction.csproj.FileListAbsolute.txt
?????文件??????11776??2011-11-27?20:53??TestSQLiteFunction\TestSQLiteFunction\obj\x86\Debug\TestSQLiteFunction.exe
?????文件????????180??2011-11-27?20:53??TestSQLiteFunction\TestSQLiteFunction\obj\x86\Debug\TestSQLiteFunction.Form1.resources
?????文件??????28160??2011-11-27?20:53??TestSQLiteFunction\TestSQLiteFunction\obj\x86\Debug\TestSQLiteFunction.pdb
............此處省略31個文件信息
評論
共有 條評論