Two types of data display without binding

Source: Internet
Author: User

/*
Tofu is made of excellent products
Http://www.asp888.net bean curd technology station
Retain the copyright information if reprinted.
*/
<% @ 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)
The first method to read data
Dim myConnection as SQLConnection
Dim dtReader AS SQLDataReader
MyConnection = new SQLConnection ("server = localhost; uid = sa; pwd =; database = northwind ")
CustomersDSCommand = new SQLDataSetCommand ("SELECT * FROM MERs", myConnection)
DsCustomer = new DataSet ()
CustomersDSCommand. FillDataSet (dsCustomer, "Customers ")
Dim Customer as DataRow
For Each Customer In dsCustomer. Tables ("MERs"). Rows
Response. Write (Customer ("CustomerId"). ToString () + "<BR> ")
Next
End Sub
Sub displaydata ()
The second Method for Data Reading
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 MERs"
Sqlcmd = New SQLCommand (SQL, sqlserver)
Sqlcmd. ActiveConnection. Open ()
Sql0000.exe cute (dtreader)
Response. write ("after opening the database, we will display the value of a field in this Table ")
While dtReader. Read ()
Response. write (dtreader. Item ("CustomerId") & "<br> ")
End While
End Sub
</Script>

<Body>
</Body>
</Html>


Author: tofu ()


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.