1
<%@ Page Language="C#"%>
2
<%@ Import Namespace="System.Data" %>
3
<%@ Import Namespace="System.Data.SqlClient" %>
4
5
<script runat=server>
6
7
void Page_Load(Object sender , EventArgs e)
8

{
9
SqlConnection conn;
10
SqlCommand cm;
11
SqlDataReader dr;
12
DataTable dt;
13
14
conn = new SqlConnection(
15
"Server=localhost;Integrated Security=SSPI;database=Bank"
16
);
17
cm = new SqlCommand( "Select * from
18
table", conn );
19
conn.Open();
20
dr = cm.ExecuteReader( CommandBehavior.KeyInfo | CommandBehavior.SchemaOnly );
21
dt = dr.GetSchemaTable();
22
dg.DataSource = dt;
23
dg.DataBind();
24
dr.Close();
25
26
conn.Close();
27
}
28
29
</Script>
30
31
<html>
32
<head><title>SqlGetSchemaTable.aspx</title></head>
33
<body>
34
35
<asp:DataGrid
36
id="dg"
37
CellPadding="4"
38
HeaderStyle-BackColor="lightgreen"
39
Runat="Server" />
40
41
</body>
42
</html>

2

3

4

5

6

7

8



9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42
