将数据库的存储过程及其参数导出来的方法
久学培训网--国内最大的培训平台! |
这两天需要将CCS里所有的存储过程导成表格的形式,拿出来分析。于是...
导出结果:
然后直接粘贴到Word文档里,就成了设计文档了,方便否?
web.config配置:
<add key="DSN" value="server = (local);database = ccs;uid=sa;pwd=***" />
代码,页面有一Label,ID为:lblStoreProcedure: 1private void BindStoreProcedure()
2 {
3 string ConnString = System.Configuration.ConfigurationSettings.AppSettings["DSN"];
4 SqlConnection conn = new SqlConnection(ConnString);
5 DataSet ds = new DataSet();
6 SqlDataAdapter da = new SqlDataAdapter("SELECT name,id FROM dbo.sysobjects WHERE (xtype = 'p') AND (LEFT(name, 2) <> 'dt')",conn);
7 da.Fill(ds);
8
9 for(int i =0 ;i<ds.Tables[0].Rows.Count;i++)
10 {
11 this.lblStoreProcedure.Text +="<b>"+Convert.ToInt32(i+1).ToString()+". "+ ds.Tables[0].Rows[i]["name"].ToString() + "<b><br>";
12 this.lblStoreProcedure.Text +="<br><b>作者:</b>";
13 this.lblStoreProcedure.Text +="<br><b>日期:</b>";
14 this.lblStoreProcedure.Text +="<br><b>说明:</b>";
15 this.lblStoreProcedure.Text +="<br><b>参数:</b>";
16 this.lblStoreProcedure.Text += "<table border = '1' bordercolor='#4D4D4D' width = '600' cellpadding='0' cellspacing='0' >";
17 this.lblStoreProcedure.Text +="<tr><td>参数</td><td>说明</td></tr>";
18 DataSet ds2 = GetDataSet(conn,ds.Tables[0].Rows[i]["id"].ToString());
19 foreach(DataRow r in ds2.Tables[0].Rows)
20 {
21 this.lblStoreProcedure.Text += "<tr>";
22 this.lblStoreProcedure.Text += "<td width='10%'>"+r["name"].ToString()+"</td>";
23 this.lblStoreProcedure.Text += "<td> </td>";
24 this.lblStoreProcedure.Text += "</tr>";
25 }
26 this.lblStoreProcedure.Text += "</table><br>";
27
28 }
29 }
30 private DataSet GetDataSet(SqlConnection conn,string id)
31 {
32
33 DataSet ds = new DataSet();
34 SqlDataAdapter da = new SqlDataAdapter("SELECT name from syscolumns where id = "+id,conn);
35 da.Fill(ds);
36 return ds;
37 }
2 {
3 string ConnString = System.Configuration.ConfigurationSettings.AppSettings["DSN"];
4 SqlConnection conn = new SqlConnection(ConnString);
5 DataSet ds = new DataSet();
6 SqlDataAdapter da = new SqlDataAdapter("SELECT name,id FROM dbo.sysobjects WHERE (xtype = 'p') AND (LEFT(name, 2) <> 'dt')",conn);
7 da.Fill(ds);
8
9 for(int i =0 ;i<ds.Tables[0].Rows.Count;i++)
10 {
11 this.lblStoreProcedure.Text +="<b>"+Convert.ToInt32(i+1).ToString()+". "+ ds.Tables[0].Rows[i]["name"].ToString() + "<b><br>";
12 this.lblStoreProcedure.Text +="<br><b>作者:</b>";
13 this.lblStoreProcedure.Text +="<br><b>日期:</b>";
14 this.lblStoreProcedure.Text +="<br><b>说明:</b>";
15 this.lblStoreProcedure.Text +="<br><b>参数:</b>";
16 this.lblStoreProcedure.Text += "<table border = '1' bordercolor='#4D4D4D' width = '600' cellpadding='0' cellspacing='0' >";
17 this.lblStoreProcedure.Text +="<tr><td>参数</td><td>说明</td></tr>";
18 DataSet ds2 = GetDataSet(conn,ds.Tables[0].Rows[i]["id"].ToString());
19 foreach(DataRow r in ds2.Tables[0].Rows)
20 {
21 this.lblStoreProcedure.Text += "<tr>";
22 this.lblStoreProcedure.Text += "<td width='10%'>"+r["name"].ToString()+"</td>";
23 this.lblStoreProcedure.Text += "<td> </td>";
24 this.lblStoreProcedure.Text += "</tr>";
25 }
26 this.lblStoreProcedure.Text += "</table><br>";
27
28 }
29 }
30 private DataSet GetDataSet(SqlConnection conn,string id)
31 {
32
33 DataSet ds = new DataSet();
34 SqlDataAdapter da = new SqlDataAdapter("SELECT name from syscolumns where id = "+id,conn);
35 da.Fill(ds);
36 return ds;
37 }
不知道有没有人可以把 @参数后的注释能够取出来?我目前还没有发现。
阿里云优惠券领取地址:https://partner.aliyun.com/shop/35783975 ,需要更多优惠请联系QQ和微信:891115,热线:400-968-4968