這文主要就是介紹 DB Browser for SQLite 如何快速完成一個小程序的增刪改查。 數據庫
SQLite Expert Professional是一款可視化的數據庫管理工具,容許用戶在 SQLite 服務器上執行建立、編輯、複製、提取等操做。SQLite Expert支持全部的圖形界面的SQLite特徵。它包括一個可視化查詢生成器,一個SQL編輯與語法突出和代碼自動完成,強大的table和view設計與導入導出功能。小程序 SQLite Expert如今分爲兩個版本,一個是免費的Personal Edition,一個是收費 Professional Edition。服務器 |
public class Mylocal
{
string conString = string.Format(@"Data Source={0}; Pooling=false; FailIfMissing=false;", System.Windows.Forms.Application.StartupPath + @"\test.db");工具
public void LogHistory(string bucketId, string fileId, string remarkName)
{
if (IsExistedTypeTable())
{
try
{
using (var dbConn = new System.Data.SQLite.SQLiteConnection(conString))
{
dbConn.Open();
using (System.Data.Common.DbCommand cmd = dbConn.CreateCommand())
{
cmd.CommandText = @"INSERT INTO TypeRecords (BucketID,FileID,TypeName,UserName) VALUES(@bucketid,@fileid,@typename,@username)";spa
var p1 = cmd.CreateParameter();
p1.ParameterName = "@bucketid";
p1.Value = bucketId;設計
var p2 = cmd.CreateParameter();
p2.ParameterName = "@fileid";
p2.Value = fileId;orm
//typename, username
var p3 = cmd.CreateParameter();
p3.ParameterName = "@typename";
p3.Value = remarkName;
var p4 = cmd.CreateParameter();
p4.ParameterName = "@username";
p4.Value = BaseBll.CrtUser;
cmd.Parameters.Add(p1);
cmd.Parameters.Add(p2);
cmd.Parameters.Add(p3);
cmd.Parameters.Add(p4);接口
cmd.ExecuteNonQuery();
cmd.Dispose();
}
if (dbConn.State != System.Data.ConnectionState.Closed) dbConn.Close();
dbConn.Dispose();
rem
}
}
catch
{
logger.Debug("寫入操做記錄時異常");
}
}
}//LogHistory
public string GetMarkNameBy(string BucketId, string FileId)//原邏輯的GetMarkBy接口
{
try
{
using (var dbConn = new System.Data.SQLite.SQLiteConnection(conString))
{
dbConn.Open();
using (System.Data.Common.DbCommand cmd = dbConn.CreateCommand())
{
//cmd.CommandText = @"INSERT INTO TypeRecords (BucketID,FileID,TypeName,UserName) VALUES(@bucketid,@fileid,@typename,@username)";cmd
//read from the table
cmd.CommandText = @"SELECT TypeName FROM TypeRecords WHERE BucketID=@bucketid AND FileID=@fileid AND UserName = @username limit 1 ";
var p1 = cmd.CreateParameter();
p1.ParameterName = "@bucketid";
p1.Value = BucketId;
var p2 = cmd.CreateParameter();
p2.ParameterName = "@fileid";
p2.Value = FileId;
var p3 = cmd.CreateParameter();
p3.ParameterName = "@username";
p3.Value = BaseBll.CrtUser;
cmd.Parameters.Add(p1);
cmd.Parameters.Add(p2);
cmd.Parameters.Add(p3);
using (System.Data.Common.DbDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
//long id = reader.GetInt64(0);
string TypeInfo = reader.GetString(0);
return TypeInfo;
}
}
cmd.Dispose();
}
if (dbConn.State != System.Data.ConnectionState.Closed) dbConn.Close();
dbConn.Dispose();
}
}
catch
{
logger.Debug("獲取歷史操做記錄數據時異常");
}
return "";
}
}