コード例 #1
0
        public object ExecuteScalar(string parCommandText, DbParamCollection parDbParameters)
        {
            this.OpenConnection();
            object obj = (object)null;

            try
            {
                obj = this.CreateCommand(parCommandText, parDbParameters).ExecuteScalar();
            }
            catch (Exception ex)
            {
            }
            this.CloseConnecion();
            return(obj);
        }
コード例 #2
0
        public int ExecuteNonQuery(string parCommandText, DbParamCollection parDbParameters)
        {
            this.OpenConnection();
            int num = 0;

            try
            {
                num = this.CreateCommand(parCommandText, parDbParameters).ExecuteNonQuery();
            }
            catch (Exception ex)
            {
            }
            this.CloseConnecion();
            return(num);
        }
コード例 #3
0
        public DbCommand CreateCommand(string parCommandText, DbParamCollection parDbParameters)
        {
            DbCommand command = this.insDbProviderFactory.CreateCommand();

            command.CommandText = parCommandText;
            command.CommandType = CommandType.StoredProcedure;
            if (parDbParameters != null)
            {
                command.Parameters.AddRange((Array)parDbParameters.ToArray());
            }
            command.Connection = this._Connection;
            if (this._Transaction != null)
            {
                command.Transaction = this._Transaction;
            }
            return(command);
        }
コード例 #4
0
        public DataTable ExecuteDataTable(string parCommandText, DbParamCollection parDbParameters, bool parIsCached)
        {
            DataTable dataTable = new DataTable();

            if (parIsCached)
            {
                if (AppDomain.CurrentDomain.GetData(parCommandText) == null)
                {
                    this.OpenConnection();
                    DbDataAdapter dataAdapter = this.insDbProviderFactory.CreateDataAdapter();
                    dataAdapter.SelectCommand = this.CreateCommand(parCommandText, parDbParameters);
                    try
                    {
                        dataAdapter.Fill(dataTable);
                    }
                    catch (Exception ex)
                    {
                    }
                    this.CloseConnecion();
                    AppDomain.CurrentDomain.SetData(parCommandText, (object)dataTable);
                }
                else
                {
                    dataTable = (DataTable)AppDomain.CurrentDomain.GetData(parCommandText);
                }
            }
            else
            {
                this.OpenConnection();
                DbDataAdapter dataAdapter = this.insDbProviderFactory.CreateDataAdapter();
                dataAdapter.SelectCommand = this.CreateCommand(parCommandText, parDbParameters);
                try
                {
                    dataAdapter.Fill(dataTable);
                }
                catch (Exception ex)
                {
                }
                this.CloseConnecion();
            }
            return(dataTable);
        }
コード例 #5
0
 public DataTable ExecuteDataTable(string parCommandText, DbParamCollection parDbParameters)
 {
     return(this.ExecuteDataTable(parCommandText, parDbParameters, false));
 }