/// <summary>
 /// The class constructor.
 /// </summary>
 /// <param name="ProcedureName">Stored procedure name or parameterized SQL statement.</param>
 /// <param name="RequestType">The request type stored procedure name or parameterized SQL.</param>
 public SpRoleAdmin(String ProcedureName, DbBaseRequestType RequestType)
     : base(ProcedureName)
 {
     DbRoleAdmin DB = new DbRoleAdmin();
     base.RequestType = RequestType;
     base.DB = DB;
 }
        /// <summary>
        /// The class constructor.
        /// </summary>
        /// <param name="ProcedureName">Stored procedure name or parameterized SQL statement.</param>
        /// <param name="RequestType">The request type stored procedure name or parameterized SQL.</param>
        public SpRoleAdmin(String ProcedureName, DbBaseRequestType RequestType)
            : base(ProcedureName)
        {
            DbRoleAdmin DB = new DbRoleAdmin();

            base.RequestType = RequestType;
            base.DB          = DB;
        }
예제 #3
0
        // Summary :
        // Does the basic job of initialising the db stuff (connection, command) and adding the parameters
        /// <param name="RequestType">Parameterized SQL text or stored procedure.</param>
        /// <param name="DatabaseProvider">Database server provider</param>
        private void Init(DbBaseRequestType RequestType)
        {
            m_strConnection = ConnectionString;

            try
            {
                m_SqlConnection = new SqlConnection(m_strConnection);

                m_SqlConnection.Open();
            }
            catch (Exception e)
            {
                if (ThrowExceptionIsOn)
                {
                    throw e;
                }

                return;
            }

            // Creates a SqlCommand and sets type
            m_SqlCommand = new SqlCommand(m_ProcedureName, (SqlConnection)m_SqlConnection);

            if (RequestType == DbBaseRequestType.ParameterizedSQLText)
            {
                m_SqlCommand.CommandType = CommandType.Text;
            }
            else if (RequestType == DbBaseRequestType.StoredProcedure)
            {
                m_SqlCommand.CommandType = CommandType.StoredProcedure;
            }

            if (this.CommandTimeOut > 0)
            {
                m_SqlCommand.CommandTimeout = this.CommandTimeOut;
            }

            // Add a return value parameter by default
            AddParameter("RETURN_VALUE", DbType.Int16, ParameterDirection.ReturnValue);

            // Adds the necessary parameters to the command
            foreach (IDbDataParameter p in m_HashParameters.Values)
            {
                m_SqlCommand.Parameters.Add(p);
            }
        }
        /// <summary>
        /// Does the basic job of initialising the db stuff (connection, command) and adding the parameters
        /// </summary>
        /// <param name="RequestType">Parameterized SQL text or stored procedure.</param>
        /// <param name="DatabaseProvider">Database server provider</param>
        private void Init(DbBaseRequestType RequestType, DatabaseProvider DatabaseProvider)
        {
            m_strConnection = DB.ConnectionString;

            try
            {
                // Opens the connection
                switch (DatabaseProvider)
                {
                case DatabaseProvider.MSSQLServer: {
                    m_SqlConnection = new SqlConnection(m_strConnection);
                    break;
                }

                case DatabaseProvider.MySQLServer:
                {
                    m_SqlConnection = new MySqlConnection(m_strConnection);
                    break;
                }

                case DatabaseProvider.ODBCSQLServer:
                {
                    m_SqlConnection = new OdbcConnection(m_strConnection);
                    break;
                }
                }

                m_SqlConnection.Open();
            }
            catch (Exception e)
            {
                if (DbBase.ThrowExceptionIsOn)
                {
                    throw e;
                }

                return;
            }

            // Creates a SqlCommand and sets type
            switch (DatabaseProvider)
            {
            case DatabaseProvider.MSSQLServer:
            {
                m_SqlCommand = new SqlCommand(m_ProcedureName, (SqlConnection)m_SqlConnection);
                break;
            }

            case DatabaseProvider.MySQLServer:
            {
                m_SqlCommand = new MySqlCommand(m_ProcedureName, (MySqlConnection)m_SqlConnection);
                break;
            }

            case DatabaseProvider.ODBCSQLServer:
            {
                m_SqlCommand = new OdbcCommand(m_ProcedureName, (OdbcConnection)m_SqlConnection);
                break;
            }
            }

            if (RequestType == DbBaseRequestType.ParameterizedSQLText)
            {
                m_SqlCommand.CommandType = CommandType.Text;
            }
            else if (RequestType == DbBaseRequestType.StoredProcedure)
            {
                m_SqlCommand.CommandType = CommandType.StoredProcedure;
            }

            if (this.CommandTimeOut > 0)
            {
                m_SqlCommand.CommandTimeout = this.CommandTimeOut;
            }

            // Add a return value parameter by default
            AddParameter("RETURN_VALUE", DbType.Int16, ParameterDirection.ReturnValue);

            // Adds the necessary parameters to the command
            foreach (IDbDataParameter p in m_HashParameters.Values)
            {
                m_SqlCommand.Parameters.Add(p);
            }
        }
        /// <summary>
        /// Does the basic job of initialising the db stuff (connection, command) and adding the parameters
        /// </summary>
        /// <param name="RequestType">Parameterized SQL text or stored procedure.</param>
        /// <param name="DatabaseProvider">Database server provider</param>
        private void Init(DbBaseRequestType RequestType, DatabaseProvider DatabaseProvider)
        {
            m_strConnection = DB.ConnectionString;

            try
            {
                // Opens the connection
                switch (DatabaseProvider)
                {
                    case DatabaseProvider.MSSQLServer: {
                        m_SqlConnection = new SqlConnection(m_strConnection);
                        break;
                    }
                    case DatabaseProvider.MySQLServer:
                    {
                        m_SqlConnection = new MySqlConnection(m_strConnection);
                        break;
                    }
                    case DatabaseProvider.ODBCSQLServer:
                    {
                        m_SqlConnection = new OdbcConnection(m_strConnection);
                        break;
                    }
                }

                m_SqlConnection.Open();
            }
            catch (Exception e)
            {
                if(DbBase.ThrowExceptionIsOn)
                    throw e;

                return;
            }

            // Creates a SqlCommand and sets type
            switch (DatabaseProvider)
            {
                case DatabaseProvider.MSSQLServer:
                {
                    m_SqlCommand = new SqlCommand(m_ProcedureName, (SqlConnection) m_SqlConnection);
                    break;
                }
                case DatabaseProvider.MySQLServer:
                {
                    m_SqlCommand = new MySqlCommand(m_ProcedureName, (MySqlConnection)m_SqlConnection);
                    break;
                }
                case DatabaseProvider.ODBCSQLServer:
                {
                    m_SqlCommand = new OdbcCommand(m_ProcedureName, (OdbcConnection) m_SqlConnection);
                    break;
                }
            }

            if (RequestType == DbBaseRequestType.ParameterizedSQLText)
                m_SqlCommand.CommandType = CommandType.Text;
            else if (RequestType == DbBaseRequestType.StoredProcedure)
                m_SqlCommand.CommandType = CommandType.StoredProcedure;

            if( this.CommandTimeOut > 0)
                m_SqlCommand.CommandTimeout = this.CommandTimeOut;

            // Add a return value parameter by default
            AddParameter( "RETURN_VALUE", DbType.Int16, ParameterDirection.ReturnValue);

            // Adds the necessary parameters to the command
            foreach( IDbDataParameter p in m_HashParameters.Values)
                m_SqlCommand.Parameters.Add(p);
        }