internal DataTable GetDataTable(string sqlCommand, DBParameterCollection paramCollection, IDbConnection connection, string tableName, CommandType commandType)
        {
            DataTable dt = null;

            if (tableName != string.Empty)
            {
                dt = new DataTable(tableName);
            }
            else
            {
                dt = new DataTable();
            }

            IDbCommand command = null;

            if (paramCollection != null)
            {
                if (paramCollection.Parameters.Count > 0)
                {
                    command = (new CommandBuilder()).GetCommand(sqlCommand, connection, paramCollection, commandType);
                }
                else
                {
                    command = (new CommandBuilder()).GetCommand(sqlCommand, connection, commandType);
                }
            }
            else
            {
                command = (new CommandBuilder()).GetCommand(sqlCommand, connection, commandType);
            }

            switch (Configuration.DBProvider.Trim().ToUpper())
            {
            case Common.SQL_SERVER_DB_PROVIDER:

                SqlDataAdapter sqlAdapter = null;
                sqlAdapter = new SqlDataAdapter((SqlCommand)command);
                try
                {
                    sqlAdapter.Fill(dt);
                }
                catch (Exception ex1)
                {
                    throw ex1;
                }
                finally
                {
                    if (command != null)
                    {
                        command.Dispose();
                    }

                    if (sqlAdapter != null)
                    {
                        sqlAdapter.Dispose();
                    }
                }
                break;

            case Common.ORACLE_DB_PROVIDER:
                OracleDataAdapter oracleAdapter = null;
                oracleAdapter = new OracleDataAdapter((OracleCommand)command);
                try
                {
                    oracleAdapter.Fill(dt);
                }
                catch (Exception ex3)
                {
                    throw ex3;
                }
                finally
                {
                    if (command != null)
                    {
                        command.Dispose();
                    }

                    if (oracleAdapter != null)
                    {
                        oracleAdapter.Dispose();
                    }
                }
                break;

            case Common.EXCESS_DB_PROVIDER:
                OleDbDataAdapter oleDBAdapterAccess = null;
                oleDBAdapterAccess = new OleDbDataAdapter((OleDbCommand)command);
                try
                {
                    oleDBAdapterAccess.Fill(dt);
                }
                catch (Exception ex4)
                {
                    throw ex4;
                }
                finally
                {
                    if (command != null)
                    {
                        command.Dispose();
                    }

                    if (oleDBAdapterAccess != null)
                    {
                        oleDBAdapterAccess.Dispose();
                    }
                }
                break;

            case Common.OLE_DB_PROVIDER:
                OleDbDataAdapter oleAdapter = null;
                oleAdapter = new OleDbDataAdapter((OleDbCommand)command);
                try
                {
                    oleAdapter.Fill(dt);
                }
                catch (Exception ex4)
                {
                    throw ex4;
                }
                finally
                {
                    if (command != null)
                    {
                        command.Dispose();
                    }

                    if (oleAdapter != null)
                    {
                        oleAdapter.Dispose();
                    }
                }
                break;

            case Common.ODBC_DB_PROVIDER:
                OdbcDataAdapter odbcAdapter = null;
                odbcAdapter = new OdbcDataAdapter((OdbcCommand)command);
                try
                {
                    odbcAdapter.Fill(dt);
                }
                catch (Exception ex4)
                {
                    throw ex4;
                }
                finally
                {
                    if (command != null)
                    {
                        command.Dispose();
                    }

                    if (odbcAdapter != null)
                    {
                        odbcAdapter.Dispose();
                    }
                }
                break;
            }

            return(dt);
        }
        internal IDataAdapter GetDataAdapter(string sqlCommand, IDbConnection connection, DBParameterCollection paramCollection, CommandType commandType)
        {
            IDataAdapter adapter = null;
            IDbCommand   command = (new CommandBuilder()).GetCommand(sqlCommand, connection, paramCollection, commandType);

            switch (Configuration.DBProvider.Trim().ToUpper())
            {
            case Common.SQL_SERVER_DB_PROVIDER:
                adapter = new SqlDataAdapter((SqlCommand)command);
                break;

            case Common.ORACLE_DB_PROVIDER:
                adapter = new OracleDataAdapter((OracleCommand)command);
                break;

            case Common.EXCESS_DB_PROVIDER:
                adapter = new OleDbDataAdapter((OleDbCommand)command);
                break;

            case Common.OLE_DB_PROVIDER:
                adapter = new OleDbDataAdapter((OleDbCommand)command);
                break;

            case Common.ODBC_DB_PROVIDER:
                adapter = new OdbcDataAdapter((OdbcCommand)command);
                break;
            }

            return(adapter);
        }
示例#3
0
 /// <summary>
 /// Executes the Sql Command and returns the DataReader.
 /// </summary>
 /// <param name="commandText">Sql Command</param>
 /// <param name="con">Database Connection object (DBHelper.GetConnObject() may be used)</param>
 /// <param name="paramCollection">Parameter to be associated with the Sql Command or Stored Procedure.</param>
 /// <returns>DataReader</returns>
 public IDataReader ExecuteDataReader(string commandText, IDbConnection con, DBParameterCollection paramCollection)
 {
     return(ExecuteDataReader(commandText, con, paramCollection, CommandType.Text));
 }
示例#4
0
 /// <summary>
 /// Executes the Sql Command and return resultset in the form of DataTable.
 /// </summary>
 /// <param name="commandText">Sql Command</param>
 /// <param name="paramCollection">Parameter collection to be associated with the Command.</param>
 /// <returns>Result in the form of DataTable</returns>
 public DataTable ExecuteDataTable(string commandText, DBParameterCollection paramCollection)
 {
     return(ExecuteDataTable(commandText, string.Empty, paramCollection, CommandType.Text));
 }
示例#5
0
 /// <summary>
 /// Executes the Sql Command and return resultset in the form of DataSet.
 /// </summary>
 /// <param name="commandText">Sql Command </param>
 /// <param name="paramCollection">Parameter collection to be associated with the command</param>
 /// <returns>Result in the form of DataSet</returns>
 public DataSet ExecuteDataSet(string commandText, DBParameterCollection paramCollection)
 {
     return(ExecuteDataSet(commandText, paramCollection, CommandType.Text));
 }
示例#6
0
 /// <summary>
 /// Executes Sql Command and returns number of rows effected.
 /// </summary>
 /// <param name="commandText">Sql Command</param>
 /// <param name="paramCollection">Parameter Collection to be associated with the command</param>
 /// <returns>Number of rows effected.</returns>
 public int ExecuteNonQuery(string commandText, DBParameterCollection paramCollection)
 {
     return(ExecuteNonQuery(commandText, paramCollection, CommandType.Text));
 }
示例#7
0
 /// <summary>
 /// Executes the Sql Command and returns result.
 /// </summary>
 /// <param name="commandText">Sql Command</param>
 /// <param name="paramCollection">Parameter collection to be associated.</param>
 /// <returns>A single value. (First row's first cell value, if more than one row and column is returned.)</returns>
 public object ExecuteScalar(string commandText, DBParameterCollection paramCollection)
 {
     return(ExecuteScalar(commandText, paramCollection, CommandType.Text));
 }