



(27 ratings)
Displaying data from a database is one of the most common uses of ASP.
Here's some sample code:
<% |
That was a simple select query.
Here it is broken down: The first two lines declare the variables Conn and SQLTemp. The next six lines open a connection to your database, and get all the rows from the table. The following Do While Not loop lets u display the data inside the row. The next four lines print out the value of each column in that row. The last bit moves to the next row, ends the loop, and closes the connection to the database.
If you decide you want the data ordered by date, you can use the following code in place of the original SQLTemp:
Adding DESC or ASC to the end of the query as such:
Not too hard, was it? The last bit we'll cover is how to limit the results, and here we'll limit it to showing only the first 30 results:
Any combination of these queries can be mixed and match to achieve results you want.
20 Random Tutorials from the same category :
Searching for Matching Values
Creating Databases
Counting Visitors In ASP
ASP.NET 2 Special Purpose Folders
Date and Time Functions In ASP
Displaying Server Values In ASP
Server Variables In ASP
Using Application Variables
Recordset Access Methods
AIM Profile Screenname Viewer as a component of AIM Profile Designs
SQL Access Methods In ASP
GLOBAL.ASA IN ASP
ASP.NET in Dreamweaver 8
DISPLAY DATA FROM DATABASE
ASP.NET Tutorial - Making image thumbnails
Passing Query Strings In Asp
ASP Components
Reading a Database
String Functions
Randomizer for ASP













