Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  ADO: Schemas to access All Data
     [next Lesson]  ADO: Update/edit Record

Displaying A Table/User Supplied Query Input

This page demonstrates the capabilities how to display a table from a SQL statement using one input variable from a user. The script to display a specified record in the table is:

   filename=/learn/test/db1parm.asp

<Test Script Below>


<TITLE>db1parm.asp</TITLE>
<body bgcolor="#FFFFFF">
<% 
' My ASP program that talks to a database
set conntemp=server.createobject("adodb.connection")
conntemp.open "DSN=Student;uid=student;pwd=magic"
p1=request.querystring("ID")
temp="select * from authors where AU_ID=" & p1
set rstemp=conntemp.execute(temp)
howmanyfields=rstemp.fields.count -1
%>
<table border=1>
<tr>
<% 'Put Headings On The Table of Field Names
for i=0 to howmanyfields %>
    <td><b><%=rstemp(i).name %></B></TD>
<% next %>
</tr>
<% ' Now lets grab all the records
do while not rstemp.eof %>
<tr>
<% for i = 0 to howmanyfields%>
    <td valign=top><% = rstemp(i) %></td>
<% next %>
</tr>
<% rstemp.movenext
loop
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing%>
</table>
</body>
</html>

There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.