示例#1
0
        internal IDataReader ExecuteReader(string strQuery)
        {
            IDataReader dataReader;

            this.ExistError = false;
            this.MsgError   = "";
            try
            {
                ProviderSQL providerSQL = new ProviderSQL()
                {
                    TipoDB = base.TypeDB
                };
                base.IConnection = providerSQL.Connection;
                base.IConnection.ConnectionString = this.StringConexion;
                base.IConnection.Open();
                base.ICommand             = base.IConnection.CreateCommand();
                base.ICommand.CommandText = strQuery;
                dataReader = base.ICommand.ExecuteReader(CommandBehavior.CloseConnection);
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                this.ExistError = true;
                this.msgError   = exception.Message.Replace("\"", "'").Replace("\r", "").Replace("\n", "\\n");
                dataReader      = null;
            }
            return(dataReader);
        }
示例#2
0
        internal IDataParameter[] AddParameters(IDataParameter[] Parameters, DbType TypeObject, ParameterDirection Direction, string ParameterName, object Value)
        {
            ProviderSQL providerSQL = new ProviderSQL();

            if (Parameters != null)
            {
                providerSQL.ParameterLenght = (int)Parameters.Length + 1;
                providerSQL.Parameters      = new IDataParameter[providerSQL.ParameterLenght];
                int i = 0;
                for (i = 0; i < (int)Parameters.Length; i++)
                {
                    providerSQL.Parameters[i] = Parameters[i];
                }
                providerSQL.Parameters[i].DbType        = TypeObject;
                providerSQL.Parameters[i].Direction     = Direction;
                providerSQL.Parameters[i].ParameterName = ParameterName;
                providerSQL.Parameters[i].Value         = Value;
            }
            else
            {
                providerSQL.ParameterLenght             = 1;
                providerSQL.Parameters                  = new IDataParameter[providerSQL.ParameterLenght];
                providerSQL.Parameters[0].DbType        = TypeObject;
                providerSQL.Parameters[0].Direction     = Direction;
                providerSQL.Parameters[0].ParameterName = ParameterName;
                providerSQL.Parameters[0].Value         = Value;
            }
            Parameters = providerSQL.Parameters;
            return(Parameters);
        }
示例#3
0
        internal IDataAdapter DataAdapter(string strQuery, IDataParameter[] param, CommandType typeCommand)
        {
            IDataAdapter dataAdapter;

            this.ExistError = false;
            this.MsgError   = "";
            IDataAdapter adapter = null;

            try
            {
                try
                {
                    ProviderSQL providerSQL = new ProviderSQL()
                    {
                        TipoDB = base.TypeDB
                    };
                    base.IConnection = providerSQL.Connection;
                    base.IConnection.ConnectionString = this.StringConexion;
                    base.IConnection.Open();
                    base.ICommand = base.IConnection.CreateCommand();
                    this.AddParameters(base.ICommand, param);
                    base.ICommand.CommandType = typeCommand;
                    base.ICommand.CommandText = strQuery;
                    providerSQL.Command       = base.ICommand;
                    adapter     = providerSQL.Adapter;
                    dataAdapter = adapter;
                    return(dataAdapter);
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    this.ExistError = true;
                    this.msgError   = exception.Message.Replace("\"", "'").Replace("\r", "").Replace("\n", "\\n");
                }
            }
            finally
            {
                base.ICommand = null;
                if ((base.IConnection == null ? false : base.IConnection.State == ConnectionState.Open))
                {
                    base.IConnection.Close();
                }
                base.IConnection = null;
            }
            dataAdapter = adapter;
            return(dataAdapter);
        }
示例#4
0

        
示例#5
0
        internal object ExecuteScalar(string strQuery)
        {
            this.ExistError = false;
            this.MsgError   = "";
            object obj = null;

            try
            {
                try
                {
                    ProviderSQL providerSQL = new ProviderSQL()
                    {
                        TipoDB = base.TypeDB
                    };
                    base.IConnection = providerSQL.Connection;
                    base.IConnection.ConnectionString = this.StringConexion;
                    base.ICommand = providerSQL.Command;
                    base.IConnection.Open();
                    base.ICommand             = base.IConnection.CreateCommand();
                    base.ICommand.CommandText = strQuery;
                    obj = base.ICommand.ExecuteScalar();
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    this.ExistError = true;
                    this.msgError   = exception.Message.Replace("\"", "'").Replace("\r", "").Replace("\n", "\\n");
                }
            }
            finally
            {
                base.ICommand = null;
                if ((base.IConnection == null ? false : base.IConnection.State == ConnectionState.Open))
                {
                    base.IConnection.Close();
                }
                base.IConnection = null;
            }
            return(obj);
        }