SQLiteHelper类
1 using System;
2 using System.Configuration;
3 using System.Data;
4 using System.Data.SQLite;
5
6 namespace MyBlog.Data
7 {
8
9 /// <summary>
10 /// SQLiteHelper
11 /// </summary>
12 public class SQLiteHelper : System.IDisposable
13 {
14 private SQLiteConnection _SQLiteConn = null;
15 private SQLiteTransaction _SQLiteTrans = null;
16 private bool _IsRunTrans = false;
17 private string _SQLiteConnString = null;
18 private bool _disposed = false;
19 private bool _autocommit = false;
20 #region 构造/析构函数
21 /// <summary>
22 /// 初始化 SQLiteHelper
23
24 /// </summary>
25 public SQLiteHelper()
26 : this(ConfigurationManager.ConnectionStrings["SQLite"].ConnectionString)
27 {
28 }
29
1 /// <summary>
2 /// 初始化 SQLiteHelper
3 /// </summary>
4 /// <param name="connectionstring">数据库连接字符串</param>
5 public SQLiteHelper(string connectionstring)
6 {
7 this._SQLiteConnString = connectionstring;
8 this._SQLiteConn = new SQLiteConnection(this._SQLiteConnString);
9 this._SQLiteConn.Commit += new SQLiteCommitHandler(_SQLiteConn_Commit);
10 this._SQLiteConn.RollBack += new EventHandler(_SQLiteConn_RollBack);
11 }
12
13 /// <summary>
14 /// SQLiteHelper 析构函数
15 /// </summary>
16 ~SQLiteHelper()
17 {
18 this.Dispose(false);
19 }
20
21 #endregion
22 #region 方法
23 /// <summary>
24 /// 打开数据库连接
25 /// </summary>
26 private void Open()
27 {
28 if (this._SQLiteConn.State == ConnectionState.Closed)
29 {
30 this._SQLiteConn.Open();
31 }
32