Esempio n. 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;
            }
        }
Esempio n. 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);
        }
Esempio n. 3
0
        public void BeginTransaction()
        {
            if (this.idbTransaction == null)
            {
                idbTransaction = DBManagerFactory.GetTransaction(this.ProviderType, idbConnection);
            }

            this.idbCommand.Transaction = idbTransaction;
        }
Esempio n. 4
0
        private IDbDataAdapter CreateCommandAndDataAdapter()
        {
            //Command and Adapter creation
            this.idbCommand = DBManagerFactory.GetCommand(this.ProviderType);
            IDbDataAdapter dataAdapter = DBManagerFactory.GetDataAdapter
                                             (this.ProviderType);

            return(dataAdapter);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public void AddParameters(string paramName, object objValue)
        {
            IDbDataParameter param = DBManagerFactory.GetParameter(this.providerType);

            param.ParameterName = paramName;
            param.Value         = objValue;
            param.Direction     = ParameterDirection.Input;

            idbParameters.Add(param);
        }
Esempio n. 7
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);
 }
Esempio n. 8
0
        public void AddParameters(string paramName, ParameterDirection direction, DbType type, object objValue = null)
        {
            IDbDataParameter param = DBManagerFactory.GetParameter(this.providerType);

            param.ParameterName = paramName;
            param.Value         = objValue;
            param.Direction     = direction;
            param.DbType        = type;

            idbParameters.Add(param);
        }
Esempio n. 9
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);
        }
Esempio n. 10
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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
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;
            }
        }
Esempio n. 13
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);
        }
Esempio n. 14
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;
     }
 }
Esempio n. 15
0
 public void CreateParameters(int paramsCount)
 {
     idbParameters = new IDbDataParameter[paramsCount];
     idbParameters = DBManagerFactory.GetParameters(this.ProviderType, paramsCount);
 }
Esempio n. 16
0
 private void GetTheCommandBuilder(IDbDataAdapter dataAdapter)
 {
     this.iDbCommandBuilder = DBManagerFactory.GetCommandBuilder(this.providerType, dataAdapter);
 }