Пример #1
0
        public static object ExecuteScalar(SQLiteConnection connection, CommandType commandType, string commandText, params SQLiteParameter[] commandParameters)
        {
            bool isLock = false;

            try
            {
                LockHelper.EnterReadLock(connection.ConnectionString, timeout);
                isLock = true;
                object result = SQLiteHelper.ExecuteScalar(connection, commandType, commandText, commandParameters);
                return(result);
            }
            finally
            {
                if (isLock)
                {
                    LockHelper.ExitReadLock(connection.ConnectionString);
                }
            }
        }
Пример #2
0
        public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText)
        {
            bool isLock = false;

            try
            {
                LockHelper.EnterReadLock(connectionString, timeout);
                isLock = true;
                DataSet result = SQLiteHelper.ExecuteDataset(connectionString, commandType, commandText);
                return(result);
            }
            finally
            {
                if (isLock)
                {
                    LockHelper.ExitReadLock(connectionString);
                }
            }
        }
Пример #3
0
        ///
        /// 读取数据以后需要自行关闭连接
        ///
        ///
        ///
        ///
        ///
        public static SQLiteDataReader ExecuteReader(SQLiteConnection connection, CommandType commandType, string commandText)
        {
            bool isLock = false;

            try
            {
                LockHelper.EnterReadLock(connection.ConnectionString, timeout);
                isLock = true;
                SQLiteDataReader result = SQLiteHelper.ExecuteReader(connection, commandType, commandText);
                return(result);
            }
            finally
            {
                if (isLock)
                {
                    LockHelper.ExitReadLock(connection.ConnectionString);
                }
            }
        }
Пример #4
0
        public static int ExecuteNonQuery(SQLiteTransaction trans, CommandType commandType, string commandText, params SQLiteParameter[] commandParameters)
        {
            bool isLock = false;

            try
            {
                //由于使用了 事物 ,所以事务不提交 其实并不会更改文件
                //so only get ReadLock
                //在事务提交时在获取写锁
                LockHelper.EnterReadLock(trans.Connection.ConnectionString, timeout);
                isLock = true;
                int result = SQLiteHelper.ExecuteNonQuery(trans, commandType, commandText, commandParameters);
                return(result);
            }
            finally
            {
                if (isLock)
                {
                    LockHelper.ExitReadLock(trans.Connection.ConnectionString);
                }
            }
        }