三度网教程:是一个免费提供流行视频软件教程、在线学习分享的学习平台!

2种没有运用绑定的 数据显示

时间:2024-1-29作者:未知来源:三度网教程人气:


/*
豆腐制作 都是精品
http://www.asp888.net 豆腐技术站
如转载 请保留版权信息
*/
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>
<html>
<script language="VB" runat="server">

Dim dsCustomer as DataSet
Dim CustomersDSCommand as SQLDataSetCommand
Protected Sub Page_Load(Src as object, E as EventArgs )
'读出数据的第一种方法
Dim myConnection as SQLConnection
Dim dtReader AS SQLDataReader
myConnection = new SQLConnection("server=localhost;uid=sa;pwd=;database=northwind")
CustomersDSCommand = new SQLDataSetCommand("SELECT * FROM customers", myConnection)
dsCustomer = new DataSet()
CustomersDSCommand.FillDataSet(dsCustomer, "Customers")
Dim Customer as DataRow
For Each Customer In dsCustomer.Tables("Customers").Rows
Response.Write(Customer("CustomerId").ToString() + "<BR>" )
Next
End Sub
Sub displaydata()
'读出数据的第二种方法
Dim dtReader AS SQLDataReader
Dim sqlcmd AS SQLCommand
Dim sqlserver AS String
Dim sql AS String
sqlserver = "server=localhost;uid=sa;password=;database=northwind"
SQL = "Select * from customers"
sqlcmd = New SQLCommand(sql,sqlserver)
sqlcmd.ActiveConnection.Open()
sqlcmd.execute(dtreader)
Response.write("再进行数据库open后,我们来显示这个Table 的某一个字段的数值")
While dtReader.Read()
response.write (dtreader.Item("CustomerId") & "<br>")
End While
End Sub
</script>

<body>
</body>
</html>


作者:豆腐()


关键词:  2种没有运用绑定的  数据显示





Copyright © 2012-2018 三度网教程(http://www.3du8.cn) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版