分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程
HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成
HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子
站长苏飞 发表于 2015-5-29 16:16 我是 新手对 数据库 和C#不是很熟悉 飞哥能 做个我看看吗 |
把数据生成一个Table,或者List然后再给Tree赋值应该就OK了。 http://www.sufeinet.com/thread-17-1-1.html我这里有个例子你看看 |
站长苏飞 发表于 2015-5-29 13:13 private void shuaxinshu() { SqlConnection conn = new SqlConnection(conn_kai); conn.Open(); string sql = string.Format("select PName from Pastern "); SqlCommand comm = new SqlCommand(sql, conn); SqlDataReader myr = comm.ExecuteReader(); while (myr.Read()) { TreeNode tn = Pasteshudel.Nodes.Add(myr.GetString(0)); SqlConnection conn1 = new SqlConnection(conn_kai1); conn1.Open(); string sql1 = string.Format("select pid from Pastern where PName='{0}'", myr.GetString(0)); SqlCommand comm1 = new SqlCommand(sql1, conn1); SqlDataReader myr1 = comm1.ExecuteReader(); if (myr1.Read()) { pid = myr1.GetInt32(0); } myr1.Close(); conn1.Close(); conn1 = new SqlConnection(conn_kai1); conn1.Open(); sql1 = string.Format("select SName from Specialty where pid={0}", pid); comm1 = new SqlCommand(sql1, conn1); myr1 = comm1.ExecuteReader(); while (myr1.Read()) { TreeNode ts=tn.Nodes.Add(myr1.GetString(0)); SqlConnection conn2 = new SqlConnection(conn_kai2); conn2.Open(); string sql2 = string.Format("select sid from Specialty where SName='{0}'", myr1.GetString(0)); SqlCommand comm2 = new SqlCommand(sql2, conn2); SqlDataReader myr2 = comm2.ExecuteReader(); if (myr2.Read()) { sid= myr2.GetInt32(0); } myr2.Close(); conn2.Close(); conn2 = new SqlConnection(conn_kai1); conn2.Open(); sql2 = string.Format("select CName from Class where sid={0}", sid); comm2 = new SqlCommand(sql2, conn2); myr2 = comm2.ExecuteReader(); while (myr2.Read()) { ts.Nodes.Add(myr2.GetString(0)); } myr2.Close(); conn2.Close(); } myr1.Close(); conn1.Close(); } myr.Close(); conn.Close(); } 这个是我 平常的 treeview 我想用三层来实现 ,但是我不知道 该怎么传节点 |
不懂你的意思,三层和treeview 有关系吗? |