zoukankan      html  css  js  c++  java
  • 获取所有子节点 父亲节点

    //子节点

      Expo.Database.SqlGen mycmd = new Expo.Database.SqlGen();
        protected void Page_Load(object sender, EventArgs e)
        {
            IList<string> path = new List<string>();
            GetPath(2, ref path);

            foreach (string s in path) {
                Response.Write(s + "<br/>");
            }
        }


        public void GetPath(int father,ref IList<string> path)
        {
            string strsql = "select id,title,father from t_Area where father=" + father.ToString();
            using (SqlDataReader dr1 = mycmd.ExecuteReader(strsql))
            {
                if (!dr1.HasRows)
                    return;
                while (dr1.Read())
                {
                    path.Add(dr1["title"].ToString());
                    GetPath(Convert.ToInt32(dr1["id"]),ref path);
                }
                dr1.Close();
                dr1.Dispose();
            }
        }

     

     

    //父亲节点

     string strsql = @" declare @tempTable TABLE
                                (
                                 [id] int,
                                 Name varchar(50),
                                 Depth int,
                                 ParentID int,
                                 Rank int
                                )
                                declare @ID int
                                set @ID={0}
                                while(@ID>0)
                                begin
                                    select @ID=ParentID from t_Category where ID=@ID;
                                    if(@ID>0)
                                    begin
                                    insert into @tempTable select * from t_Category where ID=@ID;
                                    end
                                end
                                select * from @tempTable order by id ";

  • 相关阅读:
    Understanding Convolutions
    ckeditor粘贴word图片自动上传控件
    csharp如何切片处理视频大文件
    .net如何切片处理视频大文件
    asp.net如何切片处理视频大文件
    c#如何切片处理视频大文件
    java如何切片处理视频大文件
    jsp如何切片处理视频大文件
    php如何切片处理视频大文件
    java大文件(百M以上)的上传下载讨论
  • 原文地址:https://www.cnblogs.com/aaa6818162/p/1455739.html
Copyright © 2011-2022 走看看