当前位置:首页 > 网络编程 > WEB编程 > ASP.net > 两种没有使用绑定的 数据显示

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

点击次数:20 次 发布日期:2008-11-26 23:35:47 作者:源代码网
源代码网推荐 /*
源代码网推荐豆腐制作 都是精品
源代码网推荐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>


源代码网推荐作者:豆腐()


源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华