用TreeView管理所有存储过程

列出所有存储教程名,用树形结构显示(procedureList.aspx)

HTML:
1 None.gif      < div >
2 None.gif             < asp:TreeView  ID ="treeviewProcedure"  runat ="server"   SelectedNodeStyle-BackColor ="white"   SelectedNodeStyle-BorderWidth ="1px"  SelectedNodeStyle-BorderColor ="gray"  SelectedNodeStyle-BorderStyle ="solid" >
3 None.gif                 < Nodes ></ Nodes >
4 None.gif             </ asp:TreeView >
5 None.gif          
6 None.gif     </ div >

C#:

 1 None.gif          protected   void  Page_Load( object  sender, EventArgs e)
 2 ExpandedBlockStart.gifContractedBlock.gif         dot.gif {
 3InBlock.gif            if (!Page.IsPostBack)
 4ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 5InBlock.gif
 6InBlock.gif                string cmdText = @"select  * from sys.sysObjects where xtype='p'  order by name";
 7InBlock.gif
 8InBlock.gif                fillTreeViewProcedure(cmdText);
 9InBlock.gif
10InBlock.gif                for (int i = 0; i < treeviewProcedure.Nodes[0].ChildNodes.Count; i++)
11ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
12InBlock.gif                    treeviewProcedure.Nodes[0].ChildNodes[i].CollapseAll();
13ExpandedSubBlockEnd.gif                }

14ExpandedSubBlockEnd.gif            }

15InBlock.gif           
16InBlock.gif 
17InBlock.gif            
18ExpandedBlockEnd.gif        }

19 None.gif
20 None.gif
21 None.gif         // 公共方法,填充树
22 None.gif          protected   void  fillTreeViewProcedure( string  cmdText)
23 ExpandedBlockStart.gifContractedBlock.gif         dot.gif {
24InBlock.gif            TreeNode treeNodeRoot=new TreeNode("所有存储过程");
25InBlock.gif            treeviewProcedure.Nodes.Add(treeNodeRoot);
26InBlock.gif
27InBlock.gif           
28InBlock.gif            List<string> L = new List<string>();
29InBlock.gif
30InBlock.gif            DataTable tbProcedure = SqlHelper.ExecuteDataset(Configurations.RemoteConnectionString, CommandType.Text, cmdText).Tables[0];
31InBlock.gif            for (int i = 0; i < tbProcedure.Rows.Count; i++)
32ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
33InBlock.gif                string name = tbProcedure.Rows[i]["name"].ToString();
34InBlock.gif
35InBlock.gif                string LeftName = name;
36InBlock.gif
37InBlock.gif                if (name.IndexOf('_'> 0)
38ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
39InBlock.gif                     LeftName = name.Substring(0, name.IndexOf('_'));
40ExpandedSubBlockEnd.gif                }

41InBlock.gif
42InBlock.gif                if ( treeviewProcedure.FindNode("所有存储过程/" + LeftName)==null)
43ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{              
44InBlock.gif                    TreeNode treeNode1 = new TreeNode(LeftName, LeftName);
45InBlock.gif                    treeNodeRoot.ChildNodes.Add(treeNode1);
46InBlock.gif
47InBlock.gif                    treeNode1.SelectAction = TreeNodeSelectAction.Expand;
48InBlock.gif
49InBlock.gif                    TreeNode treeNode2 = new TreeNode(name, name);
50InBlock.gif                    treeNode1.ChildNodes.Add(treeNode2);
51InBlock.gif                    treeNode2.NavigateUrl = "procedureView.aspx?id=" + name;
52InBlock.gif                    treeNode2.Target = "frmProcedureView";
53ExpandedSubBlockEnd.gif                }

54InBlock.gif                else
55ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
56InBlock.gif                    TreeNode treeNode2 = new TreeNode(name, name);
57InBlock.gif                    treeviewProcedure.FindNode("所有存储过程/" +LeftName ).ChildNodes.Add(treeNode2);
58InBlock.gif                    treeNode2.NavigateUrl = "procedureView.aspx?id=" + name;                  
59InBlock.gif                    treeNode2.Target = "frmProcedureView";
60ExpandedSubBlockEnd.gif                }
           
61InBlock.gif                
62ExpandedSubBlockEnd.gif            }

63InBlock.gif            
64ExpandedBlockEnd.gif        }


根据存储过程名,查看存储过程内容 (procedureView.aspx)
HTML:
1 None.gif      < div  style ="padding:10px;" >
2 None.gif         < asp:Repeater  ID ="repeaterProcedure"  runat ="server" >
3 None.gif             < ItemTemplate >
4 ExpandedBlockStart.gifContractedBlock.gif                 < div > <% dot.gif #Eval("text" %> </ div >
5 None.gif             </ ItemTemplate >
6 None.gif         </ asp:Repeater >
7 None.gif     </ div >

C#:

 1 None.gif          protected   string  name  =   string .Empty; //
 2 None.gif
 3 None.gif         protected   void  Page_Load( object  sender, EventArgs e)
 4 ExpandedBlockStart.gifContractedBlock.gif         dot.gif {
 5InBlock.gif            try
 6ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
 7InBlock.gif                name = Request.QueryString["id"].ToString();
 8ExpandedSubBlockEnd.gif            }

 9InBlock.gif            catch
10ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
11InBlock.gif            
12ExpandedSubBlockEnd.gif            }

13InBlock.gif 
14InBlock.gif
15InBlock.gif          //  string cmdTextGetProcedureInfoByName = @"exec sp_helpText "+name;
16InBlock.gif            string cmdTextGetProcedureInfoByName = @" declare @tb table([text]  varchar(500));
17InBlock.gif            insert @tb exec sp_HelpText  {0};
18InBlock.gif            select  * from @tb where ascii( [text]  )<>13 and len([text])<>2";
19InBlock.gif
20InBlock.gif            cmdTextGetProcedureInfoByName = string.Format(cmdTextGetProcedureInfoByName, name);
21InBlock.gif            DataTable tbGetProcedureInfoByName = SqlHelper.ExecuteDataset(Configurations.RemoteConnectionString, CommandType.Text, cmdTextGetProcedureInfoByName).Tables[0];
22InBlock.gif            repeaterProcedure.DataSource = tbGetProcedureInfoByName;
23InBlock.gif            repeaterProcedure.DataBind();
24InBlock.gif
25InBlock.gif
26InBlock.gif            
27ExpandedBlockEnd.gif        }

28 None.gif    }

转载于:https://www.cnblogs.com/cnzhouhai/archive/2007/09/18/896858.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值