資源簡介
WinForm操作SQLite 數據庫

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Data;
using?System.Data.SQLite;
namespace?SQLiteView
{
????class?DataAccess
????{
????????SQLiteConnection?con?;
????????SQLiteCommand?command;
????????public?DataAccess()
????????{
????????????con?=?new?SQLiteConnection(“Data?Source=test.db3“);
????????????command?=?con.CreateCommand();
????????}
????????//讀取數據表記錄
????????public?DataTable?ReadTable(string?tableName)
????????{
????????????command.CommandText?=?“SELECT?*?FROM?“?+?tableName;
????????????SQLiteDataAdapter?da?=?new?SQLiteDataAdapter(command);
????????????DataTable?dt?=?new?DataTable(tableName);
????????????da.Fill(dt);
????????????return?dt;
????????}
????????//修改數據表記錄
????????public?bool?UpdateTable(DataTable?srcTable?string?tableName)
????????{
????????????bool?isok?=?false;
????????????try
????????????{
????????????????command.CommandText?=?“SELECT?*?FROM?“?+?tableName;
????????????????SQLiteDataAdapter?oda?=?new?SQLiteDataAdapter(command);
????????????????SQLiteCommandBuilder?ocb?=?new?SQLiteCommandBuilder(oda);
????????????????oda.InsertCommand?=?ocb.GetInsertCommand();
????????????????oda.DeleteCommand?=?ocb.GetDeleteCommand();
????????????????oda.UpdateCommand?=?ocb.GetUpdateCommand();
????????????????oda.Update(srcTable);
????????????????isok?=?true;
????????????}
????????????catch?(Exception?ex)
????????????{}
????????????return?isok;
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3619??2012-10-30?16:37??SQLiteView.csproj
?????文件????????909??2012-10-30?16:37??SQLiteView.sln
????..A..H.?????16896??2012-10-30?16:41??SQLiteView.suo
?????文件??????10752??2012-10-30?16:41??bin\Debug\SQLiteView.exe
?????文件??????38400??2012-10-30?16:41??bin\Debug\SQLiteView.pdb
?????文件??????14328??2012-10-30?16:39??bin\Debug\SQLiteView.vshost.exe
?????文件????????490??2007-07-21?01:33??bin\Debug\SQLiteView.vshost.exe.manifest
?????文件?????488448??2006-07-16?11:21??bin\Debug\System.Data.SQLite.dll
?????文件?????157047??2006-07-16?11:20??bin\Debug\System.Data.SQLite.xm
?????文件????2094080??2012-10-30?16:39??bin\Debug\test.db3
?????文件???????4650??2012-10-30?16:37??obj\Debug\ResolveAssemblyReference.cache
?????文件????????845??2012-10-30?16:39??obj\Debug\SQLiteView.csproj.FileListAbsolute.txt
?????文件????????847??2012-10-30?16:41??obj\Debug\SQLiteView.csproj.GenerateResource.Cache
?????文件??????10752??2012-10-30?16:41??obj\Debug\SQLiteView.exe
?????文件????????180??2012-10-30?16:39??obj\Debug\SQLiteView.Form1.resources
?????文件??????38400??2012-10-30?16:41??obj\Debug\SQLiteView.pdb
?????文件????????180??2012-10-30?16:39??obj\Debug\SQLiteView.Properties.Resources.resources
?????文件???????4608??2012-10-30?16:37??obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
?????文件????????357??2008-10-11?22:22??obj\SQLiteView.csproj.FileList.txt
?????文件????????701??2009-09-03?10:50??obj\SQLiteView.csproj.FileListAbsolute.txt
?????文件???????1182??2008-10-11?15:19??Properties\AssemblyInfo.cs
?????文件???????2844??2012-10-30?16:37??Properties\Resources.Designer.cs
?????文件???????5612??2008-10-11?15:19??Properties\Resources.resx
?????文件???????1108??2012-10-30?16:37??Properties\Settings.Designer.cs
?????文件????????249??2008-10-11?15:19??Properties\Settings.settings
?????文件???????1473??2012-10-30?16:41??DataAccess.cs
?????文件???????1688??2008-10-11?22:22??Form1.cs
?????文件???????4251??2008-10-11?20:53??Form1.Designer.cs
?????文件???????5814??2008-10-11?20:53??Form1.resx
?????文件????????469??2009-09-03?09:12??Program.cs
............此處省略9個文件信息
- 上一篇:C#的DNS協議完整實現代碼
- 下一篇:畢業設計 甜橙在線音樂MP3網
評論
共有 條評論