コード例 #1
0
        // Stored Procedures -> type = true
        // Sentencias SQL    -> type = false
        public static DataSet executeDataset(String ps_command, Boolean pu_type, cls_parameter[] pa_parameters)
        {
            try
            {
                IDbCommand vu_cmd = cu_dataProvider.command(ps_command);
                foreach (cls_parameter vu_parameter in pa_parameters)
                    vu_cmd.Parameters.Add(cu_dataProvider.parameter(vu_parameter));

                DataSet vu_dts = new DataSet();
                IDbDataAdapter vu_adp = cu_dataProvider.adapter();
                vu_adp.SelectCommand = vu_cmd;

                if (pu_type.Equals(true))
                    vu_adp.SelectCommand.CommandType = CommandType.StoredProcedure;

                if (cu_transaction != null)
                {
                    vu_adp.SelectCommand.Connection = cu_transaction.Connection;
                    vu_adp.SelectCommand.Transaction = cu_transaction;
                    vu_adp.Fill(vu_dts);
                }
                else
                {
                    vu_adp.SelectCommand.Connection = getInstance().getConnection();
                    vu_adp.Fill(vu_dts);
                    closeConnection();
                }

                return vu_dts;
            }
            catch (Exception ve_exception)
            {
                throw ve_exception;
            }
        }
コード例 #2
0
        public IDataParameter parameter(cls_parameter parameter)
        {
            SqlParameter param = new SqlParameter(parameter.Nombre, parameter.Valor);

            if (parameter.Direccion == null)
                param.Direction = parameter.Direccion;

            return param;
        }
コード例 #3
0
        // Stored Procedures -> type = true
        // Sentencias SQL    -> type = false
        public static int executeNonQuery(String ps_command, Boolean pu_type, cls_parameter[] pa_parameters)
        {
            int vi_result = -1;

            try
            {
                IDbCommand vu_cmd = cu_dataProvider.command(ps_command);
                foreach (cls_parameter vu_parameter in pa_parameters)
                    vu_cmd.Parameters.Add(cu_dataProvider.parameter(vu_parameter));

                if (pu_type.Equals(true))
                    vu_cmd.CommandType = CommandType.StoredProcedure;

                if (cu_transaction != null)
                {
                    vu_cmd.Connection = cu_transaction.Connection;
                    vu_cmd.Transaction = cu_transaction;
                    vi_result = vu_cmd.ExecuteNonQuery();
                }
                else
                {
                    vu_cmd.Connection = getInstance().getConnection();
                    vi_result = vu_cmd.ExecuteNonQuery();
                    vu_cmd.Dispose();
                    closeConnection();
                }

                return vi_result;
            }
            catch (Exception ve_exception)
            {
                throw ve_exception;
            }
        }