日期:2014-05-18  浏览次数:20421 次

简单的全局变量问题、显示上次查询数据……
页面想实现的功能是,通过读取的ID,获取父级目录名称。可以是无限级的。
代码为:

        public   string   FindCat_str   =   null;
        public   string   Sql   =   null;
        public   string   RoleName   =   null;
        public   int   RoleThreadID   =   0;
        public   int   num   =   0;

        protected   string   ChaXunChild(object   Child)  
        {
                if   (Convert.ToInt32(Child).ToString()   !=   "0 ")
                {
                        Sql   =   "SELECT   Role,RoleThreadID   FROM   In_Role   WHERE   RoleID   =   "   +   Convert.ToInt32(Child)   +   " ";
                        SqlDataReader   dr   =   a.GetDataReader(Sql);
                        if   (dr.Read())  
                        {
                                RoleName   =   dr[ "Role "].ToString();
                                RoleThreadID   =   Convert.ToInt32(dr[ "RoleThreadID "].ToString());
                        }
                        dr.Close();

                        if   (FindCat_str   !=   null)
                        {
                                FindCat_str   =   FindCat_str   +   "- "   +   RoleName;
                        }
                        else  
                        {
                                FindCat_str   =   RoleName;
                        }

                        if   (RoleThreadID.ToString()   ==   "0 ")
                        {
                                return   FindCat_str;
                        }
            &