[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Display query results into HTML using ASP

Posted on 2004-10-25
6
Medium Priority
?
277 Views
Last Modified: 2008-03-17
I have an ASP page and would like the query result to display in html
my example:

dim sSQL, adoRS

sSQL = "Select UserID, UserName, UserEmail from tbl Users"

Do Until adoRS.EOF
  iSource = 0
      Do Until iSource = (adoRS.Fields.Count)
         response.write "<td>" &UserID & "</td>"
         response.write "<td>" & UserName & "</td>"
         response.write "<td>" & UserEmail & "</td>"
         iSource = iSource + 1
   Loop
   adoRS.MoveNext
Loop
adoRS.close

How should I do this??  Any help appreciated.. Thanks in Advance.
0
Comment
Question by:sl1nger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 10

Accepted Solution

by:
m8rix earned 2000 total points
ID: 12406797
Hi sl1nger! Is this what you mean?

dim sSQL, adoRS

sSQL = "Select UserID, UserName, UserEmail from tbl Users"

response.write "<table>"
Do Until adoRS.EOF
   response.write "<tr>"  
   response.write "<td>" & adoRS("UserID") & "</td>"
   response.write "<td>" & adoRS("UserName") & "</td>"
   response.write "<td>" & adoRS("UserEmail") & "</td>"
   response.write "</tr>"
   adoRS.MoveNext
Loop
response.write "</table>"
adoRS.close
0
 
LVL 15

Expert Comment

by:gladxml
ID: 12407393
you can also try this...

===
<%
dim sSQL, adoRS
set adoRS=Server.CreateObject("ADODB.recordset")
sSQL = "Select UserID, UserName, UserEmail from tbl Users"
'assuming that your connection object is conn then
rs.Open sql, conn
%>
<table>
<%
if not(adoRS.EOF) then
Do while not(adoRS.EOF)%>
  <tr>  
   <td><%=adoRS("UserID")%></td>
   <td><%=adoRS("UserName")%></td>
  <td><%=adoRS("UserEmail")%></td>
   </tr>
   <%adoRS.MoveNext
Loop
end if
adoRS.close%>
</table>

===

You can also look at the link below might help...

http://www.w3schools.com/ado/ado_query.asp

HTH...

Happy programming...

0
 
LVL 6

Expert Comment

by:casstd
ID: 12408025
Hi,

         This is another way of displaying with the Table Headings.

Response.write "<table border=1 cellspacing=1 cellpadding=1>"
Response.write "<TR>"
Response.write "<td valign=top>No</TD>"
Response.write "<td valign=top>UserID</TD>"
Response.write "<td valign=top>User Name</TD>"
Response.write "<td valign=top>Email</TD>"
Response.write "</tr>"

dim sSQL, adoRS
iSource = 0
sSQL = "Select UserID, UserName, UserEmail from tbl Users"
set adoRS = Dbobj.execute(ssql)

if not adoRS.EOF then
  Do Until adoRS.EOF
       iSource = iSource + 1
         Response.write "<TR>"
         response.write "<td>" &iSource& "</td>"
         response.write "<td>" &adoRS("UserID")& "</td>"
         response.write "<td>" & adoRS("UserName")&  "</td>"
         response.write "<td>" & adoRS("UserEmail")&  "</td>"
         Response.write "</tr>"
         adoRS.MoveNext
   Loop
end if

Response.write "</table>"
adoRS.close

Hope this would be Helpful to you.

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:sl1nger
ID: 12411155
How can I add a row count?  If possible, I'd like to display the number of results; w/out writing another query.
0
 

Author Comment

by:sl1nger
ID: 12411210
I'd also like to alternate colors between each row. White, grey, white, grey, etc.
0
 
LVL 10

Expert Comment

by:m8rix
ID: 12416895
Hi sl1nger, thanks for the points!

The following code will answer your additional questions.

Reg's
m8rix

<%
dim sSQL, adoRS

sSQL = "Select UserID, UserName, UserEmail from tbl Users"
BackColor = "#FFFFFF"
Counter = 0

response.write "<table>"
Do Until adoRS.EOF
   Counter = Counter + 1
   if BackColor = "#FFFFFF" then
      BackColor = "#FBFBFB"
   Else
      BackColor = "#FFFFFF"
   End if
   response.write "<tr style=""background-color: " & BackColor & """>"  
   response.write "<td>" & Counter & "</td>"
   response.write "<td>" & adoRS("UserID") & "</td>"
   response.write "<td>" & adoRS("UserName") & "</td>"
   response.write "<td>" & adoRS("UserEmail") & "</td>"
   response.write "</tr>"
   adoRS.MoveNext
Loop
response.write "</table>"
adoRS.close
%>
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question