Tutorials to .com

ASP.NET Development Articles

Can't Find What You're Looking For?

Tutorials to .com » Dotnet » Development » Do not use two kinds of data binding

Do not use two kinds of data binding

Print View , by: iSee ,Total views: 3 ,Word Count: 349 ,Date: Mon, 24 Aug 2009 Time: 10:08 AM

/ *
Tofu is fine
technical points such as tofu http://www.asp888.net reprint information, please retain the copyright
* /
<% @ Import Namespace = "System.Data"%>
<% @ Import Namespace = "System.Data.SQL"%>
<script language="VB" runat="server">

Dim dsCustomer as DataSet
Dim CustomersDSCommand as SQLDataSetCommand
Protected Sub Page_Load (Src as object, E as EventArgs)
Sensed data of the first method
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>")
End Sub
Sub displaydata ()
The second method of read data
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 ( "re-open the database, we have to show a certain field of this Table value")
While dtReader.Read ()
response.write (dtreader.Item ( "CustomerId") & "<br>")
End While
End Sub
</ script>

</ body>
</ html>

Author: tofu ()


Rating: Not yet rated


No comments posted.