1 void yang dilindungi Button1_Click(pengirim objek, EventArgs e)
2 {
3 //得到目前内网可用的SqlServer
4 Contoh System.Data.Sql.SqlDataSourceEnumerator = SqlDataSourceEnumerator.Instance;
5 DataTable dt1 = instance.GetDataSources();
6 Response.Write("目前内网可用的SqlServer" + "<br/>");
7 foreach (DataRow dr di dt1.Rows)
8 {
9 Respon.Write(dr[0].ToString() + "<br/>");
10 }
11 Respon.Tulis("===========");
12 //得到某数据库 的 架构集合
13 string strConn = "Sumber Data=192.168.0.36;Katalog Awal=NorthWind;Info Keamanan Tetap=Benar;ID Pengguna=sa;Kata Sandi=sa";
14 Sistem.Data.SqlClient.SqlConnection samb = SqlConnection baru(strConn);
15 samb.Buka();
16 DataTable dt2 = samb.GetSchema();
17 Response.Write("数据库 的 架构集合"+"<br/>");
18 Response.Write("<batas tabel='1'>");
19 foreach (baris System.Data.DataRow di dt2.Rows)
20 {
21 Respon.Write("<tr>");
22 foreach (kolom System.Data.DataColumn di dt2.Columns)
23 {
24 Response.Write("<td>"+col.ColumnName + "</td><td>" + baris[col]+"</td>");
25 }
26 Respon.Write("<tr/>");
27 }
28 Respon.Write("</table>");
29
30 //具体应用 得到某数据库下的用户表名
31 //string strConn = "Sumber Data=192.168.0.36;Katalog Awal=NorthWind;Info Keamanan Tetap=Benar;ID Pengguna=sa;Kata Sandi=sa";
32 //Sistem.Data.SqlClient.SqlConnection samb = new SqlConnection(strConn);
33 //sambungan.Buka();
34 string[] strArray = string baru[4];
35 strArray[3] = "TABEL DASAR";// LIHAT
36 DataTable dt3 = conn.GetSchema("Tabel", strArray);
37 Respon.Tulis("================== ");
38 Response.Write("某数据库下的用户表名");
39 foreach (DataRow dr di dt3.Rows)
40 {
41 Respon.Write(dr["TABLE_NAME"].ToString());
42 Respon.Tulis("<br/>");
43 }
44
45 }
http://www.cnblogs.com/freeliver54/archive/2006/12/13/590506.html