Пример #1
0
        public DataTable ExecuteDataTable(CommandType commandType, string
                                          commandText)
        {
            try
            {
                this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
                PrepareCommand(idbCommand, this.Connection, this.Transaction,
                               commandType,
                               commandText, this.Parameters);
                IDbDataAdapter dataAdapter = DBManagerFactory.GetDataAdapter
                                                 (this.ProviderType);
                dataAdapter.SelectCommand = idbCommand;
                DataSet dataSet = new DataSet();
                dataAdapter.Fill(dataSet);
                idbCommand.Parameters.Clear();
                if (dataSet.Tables.Count > 0)
                {
                    return(dataSet.Tables[0]);
                }

                return(null);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        public object ExecuteScalar(CommandType commandType, string commandText)
        {
            this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
            PrepareCommand(idbCommand, this.Connection, this.Transaction, commandType, commandText, this.Parameters);
            object returnValue = idbCommand.ExecuteScalar();

            idbCommand.Parameters.Clear();
            return(returnValue);
        }
Пример #3
0
        private IDbDataAdapter CreateCommandAndDataAdapter()
        {
            //Command and Adapter creation
            this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
            IDbDataAdapter dataAdapter = DBManagerFactory.GetDataAdapter
                                             (this.ProviderType);

            return(dataAdapter);
        }
Пример #4
0
        public IDataReader ExecuteReader(CommandType commandType, string commandText)
        {
            this.idbCommand       = DBManagerFactory.GetCommand(this.ProviderType);
            idbCommand.Connection = this.Connection;
            PrepareCommand(idbCommand, this.Connection, this.Transaction, commandType, commandText, this.Parameters);
            this.DataReader = idbCommand.ExecuteReader();
            idbCommand.Parameters.Clear();

            return(this.DataReader);
        }
Пример #5
0
 public void Open()
 {
     idbConnection =
         DBManagerFactory.GetConnection(this.providerType);
     idbConnection.ConnectionString = this.ConnectionString;
     if (idbConnection.State != ConnectionState.Open)
     {
         idbConnection.Open();
     }
     this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
 }
Пример #6
0
        public DataSet ExecuteDataSet(CommandType commandType, string commandText)
        {
            this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
            PrepareCommand(idbCommand, this.Connection, this.Transaction, commandType, commandText, this.Parameters);
            IDbDataAdapter dataAdapter = DBManagerFactory.GetDataAdapter(this.ProviderType);

            dataAdapter.SelectCommand = idbCommand;
            DataSet dataSet = new DataSet();

            dataAdapter.Fill(dataSet);
            idbCommand.Parameters.Clear();
            return(dataSet);
        }
Пример #7
0
        public IDataReader ExecuteReader(CommandType commandType, string commandText)
        {
            if (this.Connection == null)
            {
                Open();
            }

            this.idbCommand       = DBManagerFactory.GetCommand(this.ProviderType);
            idbCommand.Connection = this.Connection;
            PrepareCommand(idbCommand, this.Connection, this.Transaction, commandType, commandText, this.Parameters);
            this.DataReader = idbCommand.ExecuteReader();
            // TODO: only clear out parameters if none of the parameters are of type output
            //idbCommand.Parameters.Clear();
            return(this.DataReader);
        }
Пример #8
0
        public object ExecuteScalar(CommandType commandType, string commandText)
        {
            if (this.Connection == null)
            {
                Open();
            }

            this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
            PrepareCommand(idbCommand, this.Connection, this.Transaction, commandType, commandText, this.Parameters);
            object returnValue = idbCommand.ExecuteScalar();

            // TODO: only clear out parameters if none of the parameters are of type output
            // idbCommand.Parameters.Clear();
            return(returnValue);
        }
Пример #9
0
        public int ExecuteNonQuery(CommandType commandType, string
                                   commandText)
        {
            try
            {
                this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
                PrepareCommand(idbCommand, this.Connection, this.Transaction,
                               commandType, commandText, this.Parameters);
                int returnValue = idbCommand.ExecuteNonQuery();

                idbCommand.Parameters.Clear();
                return(returnValue);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #10
0
        public DataSet ExecuteDataSet(CommandType commandType, string commandText)
        {
            if (this.Connection == null)
            {
                Open();
            }
            this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
            this.idbCommand.CommandTimeout = 0;
            PrepareCommand(idbCommand, this.Connection, this.Transaction, commandType, commandText, this.Parameters);
            IDbDataAdapter dataAdapter = DBManagerFactory.GetDataAdapter(this.ProviderType);

            dataAdapter.SelectCommand = idbCommand;
            DataSet dataSet = new DataSet();

            dataAdapter.Fill(dataSet);
            // TODO: only clear out parameters if none of the parameters are of type output
            // idbCommand.Parameters.Clear();
            return(dataSet);
        }
Пример #11
0
 public DataSet SetDataSetForUpdate(CommandType commandType, string
                                    commandText)
 {
     try
     {
         this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
         PrepareCommand(idbCommand, this.Connection, this.Transaction,
                        commandType,
                        commandText, this.Parameters);
         IDbDataAdapter dataAdapter = DBManagerFactory.GetDataAdapter
                                          (this.ProviderType);
         dataAdapter.SelectCommand = idbCommand;
         UpdateDataSet             = new DataSet();
         dataAdapter.Fill(UpdateDataSet);
         idbCommand.Parameters.Clear();
         return(UpdateDataSet);
     }
     catch (Exception)
     {
         throw;
     }
 }