Example #1
0
        public override SQLiteDataReader ExecuteDataReader(SQLiteParam procParam)
        {
            Stopwatch        _stopwatch = null;
            SQLiteDataReader reader     = null;

            try
            {
                //this.executionStartTime = DateTime.Now;
                _stopwatch = new Stopwatch();

                _stopwatch.Start();

                reader = base._getReader(procParam);

                _stopwatch.Stop();
                //this.executionStopTime = DateTime.Now;
            }
            catch (Exception ex)
            {
                base.lastException = ex;
                throw ex;
            }
            finally
            {
                //base.ExecuteTime = this.executionStopTime - this.executionStartTime;
                _stopwatch = null;
            }

            return(reader);
        }
        protected SQLiteDataReader _getReader(SQLiteParam param)
        {
            if (this.Connection == null)
            {
                return(null);
            }

            SQLiteCommand ret = new SQLiteCommand();

            ret.CommandType    = CommandType.Text;
            ret.CommandText    = param.CommandText;
            ret.Connection     = this.Connection;
            ret.CommandTimeout = 0;

            if (this.IsTransactionActive)
            {
                if (this.currentTransaction != null)
                {
                    ret.Transaction = this.currentTransaction;
                }
                else
                {
                    throw new MSDataLayerException("Cannot assign null transaction to command.");
                }
            }

            if (param.Parameters != null)
            {
                this.SetParaMeterToCommand(ref ret, param.Parameters);
            }

            return(ret.ExecuteReader());
        }
Example #3
0
        public override object ExecuteScalar(SQLiteParam procParam)
        {
            Stopwatch     _stopwatch = null;
            SQLiteCommand cmd        = null;
            object        objScalar  = null;

            try
            {
                //this.executionStartTime = DateTime.Now;
                _stopwatch = new Stopwatch();

                base.BeginTransaction();
                cmd = base._getCommand(procParam);

                if (cmd != null)
                {
                    _stopwatch.Start();
                    objScalar = cmd.ExecuteScalar();
                    _stopwatch.Stop();
                }
                else
                {
                    throw new MSDataLayerException("Command cannot be created since connection is not initialized.");
                }

                this.lastException = null;
                base.CommitTransaction();

                //this.executionStopTime = DateTime.Now;
            }
            catch (MSDataLayerException tEx)
            {
                base.RollbackTransaction();
                objScalar = null;
                throw tEx;
            }
            catch (Exception ex)
            {
                base.RollbackTransaction();
                objScalar          = null;
                this.lastException = ex;
            }
            finally
            {
                //base.ExecuteTime = this.executionStopTime - this.executionStartTime;
                _stopwatch = null;

                cmd.Dispose();
                cmd = null;
            }

            return(objScalar);

            throw new NotImplementedException();
        }
Example #4
0
        public override int ExecuteNonQuery(SQLiteParam procParam)
        {
            Stopwatch     _stopwatch = null;
            SQLiteCommand cmd        = null;
            int           ret        = 0;

            try
            {
                //this.executionStartTime = DateTime.Now;
                _stopwatch = new Stopwatch();

                base.BeginTransaction();

                cmd = base._getCommand(procParam);

                if (cmd != null)
                {
                    _stopwatch.Start();

                    ret = cmd.ExecuteNonQuery();

                    _stopwatch.Stop();
                }
                else
                {
                    throw new MSDataLayerException("Command cannot be created since connection is not initialized.");
                }

                this.lastException = null;
                base.CommitTransaction();

                //this.executionStopTime = DateTime.Now;
            }
            catch (MSDataLayerException tEx)
            {
                base.RollbackTransaction();
                throw tEx;
            }
            catch (Exception ex)
            {
                base.RollbackTransaction();
                ret = SQLiteDataAccess.ERROR_RESULT; this.lastException = ex;
            }
            finally
            {
                //base.ExecuteTime = this.executionStopTime - this.executionStartTime;
                _stopwatch = null;

                cmd.Dispose();
                cmd = null;
            }

            return(ret);
        }
Example #5
0
        public override DataTable GetDataTable(SQLiteParam procParam, string tableName)
        {
            Stopwatch         _stopwatch = null;
            SQLiteCommand     cmd        = null;
            SQLiteDataAdapter dap        = null;
            DataTable         dtb        = new DataTable(tableName);

            try
            {
                //this.executionStartTime = DateTime.Now;
                _stopwatch = new Stopwatch();

                dtb.BeginLoadData();
                _stopwatch.Start();

                cmd = base._getCommand(procParam);
                dap = new SQLiteDataAdapter(cmd);
                dap.Fill(dtb);

                _stopwatch.Stop();
                dtb.EndLoadData();

                //this.executionStopTime = DateTime.Now;
            }
            catch (Exception ex)
            {
                base.lastException = ex;
                throw ex;
            }
            finally
            {
                //base.ExecuteTime = this.executionStopTime - this.executionStartTime;
                _stopwatch = null;

                cmd.Dispose();
                cmd = null;

                dap.Dispose();
                dap = null;
            }

            return(dtb);
        }
 public abstract SQLiteDataReader ExecuteDataReader(SQLiteParam procParam);
 public abstract object ExecuteScalar(SQLiteParam procParam);
 public abstract int ExecuteNonQuery(SQLiteParam procParam);
 public abstract DataTable GetDataTable(SQLiteParam procParam, string tableName);
 public abstract DataTable GetDataTable(SQLiteParam procParam);