两种没有使用绑定的 数据显示

/*
豆腐制作 都是精品
http://www.asp888.net 豆腐技术站
如转载 请保留版权信息
*/

1@ Import Namespace="System.Data" 
1@ Import Namespace="System.Data.SQL" 
 1<html>
 2<script language="VB" runat="server">
 3
 4Dim dsCustomer as DataSet   
 5Dim CustomersDSCommand as SQLDataSetCommand   
 6Protected Sub Page_Load(Src as object, E as EventArgs )   
 7'读出数据的第一种方法   
 8Dim myConnection as SQLConnection   
 9Dim dtReader AS SQLDataReader   
10myConnection = new SQLConnection("server=localhost;uid=sa;pwd=;database=northwind")   
11CustomersDSCommand = new SQLDataSetCommand("SELECT * FROM customers", myConnection)   
12dsCustomer = new DataSet()   
13CustomersDSCommand.FillDataSet(dsCustomer, "Customers")   
14Dim Customer as DataRow   
15For Each Customer In dsCustomer.Tables("Customers").Rows   
16Response.Write(Customer("CustomerId").ToString() + "<BR>" )   
17Next   
18End Sub   
19Sub displaydata()   
20'读出数据的第二种方法   
21Dim dtReader AS SQLDataReader   
22Dim sqlcmd AS SQLCommand   
23Dim sqlserver AS String   
24Dim sql AS String   
25sqlserver = "server=localhost;uid=sa;password=;database=northwind"   
26SQL = "Select * from customers"   
27sqlcmd = New SQLCommand(sql,sqlserver)   
28sqlcmd.ActiveConnection.Open()   
29sqlcmd.execute(dtreader)   
30Response.write("再进行数据库open后,我们来显示这个Table 的某一个字段的数值")   
31While dtReader.Read()   
32response.write (dtreader.Item("CustomerId") & "<br>")   
33End While   
34End Sub   
35</script>
36<body>
37</body>
38</html>

作者:豆腐()

Published At
Categories with Web编程
Tagged with
comments powered by Disqus