資源簡介
用C#實現了對sqlite數據庫的操作,包括動態連接庫的引用,數據庫操作類,增刪改查,操作方便。

代碼片段和文件信息
using?System;
using?System.Data;
using?System.Text.Regularexpressions;
using?System.xml;
using?System.IO;
using?System.Collections;
using?System.Data.SqlClient;
using?System.Data.SQLite;
namespace?Carbinet
{
????///?
????///?SQLiteHelper?is?a?utility?class?similar?to?“SQLHelper“?in?MS
????///?Data?Access?Application?Block?and?follows?similar?pattern.
????///?
????public?class?CsharpSQLiteHelper
????{
????????public?static?string?connectString?=?“Data?Source=“?+?System.Windows.Forms.Application.StartupPath?+?“\\lg.db3“;
????????//string?cs?=?string.Format(“Version=3uri=file:{0}“?dbFilename);
????????///?
????????///?Creates?a?new? ?instance.?The?ctor?is?marked?private?since?all?members?are?static.
????????///?
????????private?CsharpSQLiteHelper()
????????{
????????}
????????//public?static?object?ExecuteScalar(string?commandText?object[]?paramList)
????????//{
????????//????SQLiteConnection?cn?=?new?SQLiteConnection(connectString);
????????//????IDbCommand?cmd?=?cn.CreateCommand();
????????//????cmd.CommandText?=?commandText;
????????//????if?(null?!=?paramList)
????????//????{
????????//????????cmd.CommandText?=?string.Format(commandText?paramList);
????????//????}
????????//????if?(cn.State?==?ConnectionState.Closed)
????????//????????cn.Open();
????????//????object?result?=?cmd.ExecuteScalar();
????????//????cmd.Dispose();
????????//????cn.Close();
????????//????return?result;
????????//}
????????public?static?int?ExecuteNonQuery(string?commandText?object[]?paramList)
????????{
????????????SQLiteConnection?cn?=?new?SQLiteConnection(connectString);
????????????IDbCommand?cmd?=?cn.CreateCommand();
????????????cmd.CommandText?=?commandText;
????????????if?(null!=paramList)
????????????{
????????????????cmd.CommandText?=?string.Format(commandText?paramList);
????????????}
????????????if?(cn.State?==?ConnectionState.Closed)
????????????????cn.Open();
????????????int?result?=?cmd.ExecuteNonQuery();
????????????cmd.Dispose();
????????????cn.Close();
????????????return?result;
????????}
????????///?
????????///?Shortcut?to?ExecuteNonQuery?with?SQLStatement?and?object[]?param?values
????????///?
????????///?SQLite?Connection?String
????????///?SQL?Statement?with?embedded?“@param“?style?parameters
????????///?object[]?array?of?parameter?values
????????///?
????????public?static?int?ExecuteNonQuery(string?connectionString?string?commandText?object[]?paramList)
????????{
????????????SQLiteConnection?cn?=?new?SQLiteConnection(connectionString);
????????????IDbCommand?cmd?=?cn.CreateCommand();
????????????cmd.CommandText?=?commandText;
????????????if?(paramList?!=?null)
????????????{
????????????????cmd.CommandText?=?string.Format(commandText?paramList);
???????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-12-19?11:03??登陸\
?????文件?????????246??2014-12-19?10:45??登陸\app.config
?????目錄???????????0??2014-12-19?11:03??登陸\bin\
?????目錄???????????0??2014-12-19?11:03??登陸\bin\Debug\
?????文件???????83968??2014-12-19?11:02??登陸\bin\Debug\lg.db3
?????文件??????904704??2010-11-23?18:42??登陸\bin\Debug\System.Data.SQLite.DLL
?????文件???????49664??2014-12-19?11:02??登陸\bin\Debug\登陸.exe
?????文件?????????246??2014-12-19?10:45??登陸\bin\Debug\登陸.exe.config
?????文件???????65024??2014-12-19?11:02??登陸\bin\Debug\登陸.pdb
?????文件???????14328??2014-12-19?10:34??登陸\bin\Debug\登陸.vshost(1).exe
?????文件???????22712??2014-12-26?20:40??登陸\bin\Debug\登陸.vshost.exe
?????文件?????????490??2014-12-19?10:34??登陸\bin\Debug\登陸.vshost.exe(1).manifest
?????文件?????????246??2014-12-19?10:45??登陸\bin\Debug\登陸.vshost.exe.config
?????文件?????????490??2012-06-02?22:34??登陸\bin\Debug\登陸.vshost.exe.manifest
?????文件????????5546??2014-12-19?11:02??登陸\CsharpSQLiteHelper.cs
?????文件????????2160??2014-12-19?10:39??登陸\Form1.cs
?????文件????????4747??2014-12-19?10:33??登陸\Form1.Designer.cs
?????文件????????5814??2014-12-19?10:33??登陸\Form1.resx
?????文件????????1177??2014-12-19?11:02??登陸\Frm_user.cs
?????文件???????12625??2014-12-19?10:53??登陸\Frm_user.Designer.cs
?????文件????????8603??2014-12-19?10:53??登陸\Frm_user.resx
?????文件????????4269??2014-12-19?10:53??登陸\MDIParent1.cs
?????文件???????39554??2014-12-19?10:41??登陸\MDIParent1.Designer.cs
?????文件???????27570??2014-12-19?10:41??登陸\MDIParent1.resx
?????目錄???????????0??2014-12-19?11:03??登陸\obj\
?????目錄???????????0??2014-12-19?11:03??登陸\obj\Debug\
?????文件?????????791??2014-12-19?10:35??登陸\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件????????6993??2014-12-26?20:40??登陸\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????目錄???????????0??2014-12-19?10:33??登陸\obj\Debug\TempPE\
?????文件????????2550??2014-12-26?20:40??登陸\obj\Debug\登陸.csproj.FileListAbsolute.txt
?????文件?????????971??2014-12-19?10:53??登陸\obj\Debug\登陸.csproj.GenerateResource.Cache
............此處省略16個文件信息
- 上一篇:基于asp.net的bbs系統
- 下一篇:c# / VB 調用refprop.dll
評論
共有 條評論