< %@ Import Namespace="System.Data" %>
1@ Import Namespace="System.Data.SQL"
1<html>
2
3< script language="C#" runat="server">
4'声明C#
5
6public DataSet dsCustomer;
7
8protected void Page_Load(Object Src, EventArgs E )
9
10{
11'当打开页面时联结数据库
12
13SQLConnection myConnection = new SQLConnection
14("server=sql2.bitsonthewire.com;uid=joeuser;pwd=joeuser;database=northwind");
15
16SQLDataSetCommand CustomersDSCommand = new SQLDataSetCommand("select * from customers", myConnection);
17dsCustomer = new DataSet();
18
19
20CustomersDSCommand.FillDataSet(dsCustomer,"Customers");
21
22foreach (DataRow Customer in dsCustomer.Tables["Customers"].Rows)
23
24{
25
26Response.Write(Customer["CustomerId"].ToString() + "<br/> " ); } }
27
28
29<body>
30</body>
31</html>