コード例 #1
0
        public object fun_ejecutar_script(string bd, string sp, string tipo = "text")
        {
            ConexionDAO objCn = new ConexionDAO();

            using (SqlConnection cn = new SqlConnection(objCn.conex(bd)))
            {
                cn.Open();
                SqlCommand cmd = new SqlCommand(sp, cn);
                cmd.CommandType = (tipo == "text") ? CommandType.Text : CommandType.StoredProcedure;
                object x = cmd.ExecuteScalar();
                return(x);
            }
        }
コード例 #2
0
        public DataTable fun_ejecutar_script_dt(string bd, string sp, string tipo = "text")
        {
            ConexionDAO objCn = new ConexionDAO();

            using (SqlConnection cn = new SqlConnection(objCn.conex(bd)))
            {
                cn.Open();
                SqlDataAdapter da = new SqlDataAdapter(sp, cn);
                if (tipo == "text")
                {
                    da.SelectCommand.CommandType = CommandType.Text;
                }
                else
                {
                    da.SelectCommand.CommandType = CommandType.StoredProcedure;
                }

                DataTable dt = new DataTable();
                da.Fill(dt);
                return(dt);
            }
        }