一场误会

Standing On Shoulders of Gaint

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

1、数据库设计:ID,Name,ParaentID,Detail
2、代码:
   

 1   public string[] GetDeptID(int DeptID)
 2    {
 3        string PersonName = "";
 4        // int id = (int)AppendixID;
 5        SqlConnection conn;
 6        SqlCommand comm;
 7        MX.Data.Connection myconn = new MX.Data.Connection();
 8        conn = myconn.SqlConnection;
 9        string sSql = "select ID  from Sys_Org_Info  where ParentID = " + DeptID;
10        comm = new SqlCommand(sSql, conn);
11        conn.Open();
12        SqlDataReader rs = comm.ExecuteReader();
13        while(rs.Read())
14        {
15            arr[i++= rs["ID"].ToString().Trim();
16
17        }

18        conn.Close();
19        if(j<i)
20        {
21            GetDeptID(Convert .ToInt32(arr[j++]));
22        }

23        return arr;
24
25    }

26前台获取的代码:
27string[] deptarr = Dept.GetDeptID(DeptID);
28        for (int k = 0; k < deptarr.Length; k++)
29        {
30            if (deptarr[k] != null)
31                strdept += deptarr[k] + ",";
32        }

33        strdept += DeptID.ToString(); 
34
posted on 2007-01-29 20:13  一场误会  阅读(242)  评论(0)    收藏  举报