Need help with printing results from an SQL query in ASP VBScript 
Author Message
 Need help with printing results from an SQL query in ASP VBScript

I have a file that queries a MySQL db.  I want to run a loop to print
the results.  I know the MySQL line works, butI'm only getting one
result (that I know of).  I can only print the first result.  There
should be 28 from my query.  Can someone help with making a loop to
print ALL the results?  Here's what I have so far:

        <%
          DIM SQL
          DIM RSA()
          DIM BGC
          DIM User
          DIM i

          txtLastName = Request.Form("txtLastName")

          if txtLastName = ""  then Response.Redirect
"getlastname.asp?Action=Blank" end if

            SQL = "SELECT LName, FName, IP FROM user WHERE LName = '" &
txtLastName & "' ORDER BY FName"
            Set RSA = conn.Execute(SQL,,adCmdText)
                BGC = "BDBDFF"

            Response.Write "<tr>"
            Response.Write "<td bgcolor=" & BGC & " width=190 height=30
align=left> " & RSA.Fields("LName").Value & "</td>"
            Response.Write "<td bgcolor=" & BGC & " width=190 height=30
align=left> " & RSA.Fields("FName").Value & "</td>"
            Response.Write "<td bgcolor=" & BGC & " width=190 height=30
align=right> " & RSA.Fields("IP").Value & "</td>"
            Response.Write "</tr>"

        %>



Mon, 31 Jan 2005 22:11:26 GMT  
 Need help with printing results from an SQL query in ASP VBScript
ok try this...

<%
DIM RSA,Cnn,SQL
DIM BGC
DIM User
DIM i

txtLastName = Request.Form("txtLastName")
if txtLastName = ""  then
        Response.Redirect "getlastname.asp?Action=Blank"
else
        SQL = "SELECT LName, FName, IP FROM user WHERE
LName = '" &
                txtLastName & "' ORDER BY FName"
        set RSA = Server.CreateObject("ADODB.Recordset")
        Set RSA = conn.Execute(SQL,,adCmdText)
        BGC = "BDBDFF"
        If not RSA.EOF and not RSA.BOF then
                Do while not RSA.EOF
                        Response.Write "<tr>"
                        Response.Write "<td bgcolor=" &
BGC & " width=190 height=30 align=left> " & RSA.Fields
("LName").Value & "</td>"
                        Response.Write "<td bgcolor=" &
BGC & " width=190 height=30 align=left> " & RSA.Fields
("FName").Value & "</td>"
                        Response.Write "<td bgcolor=" &
BGC & " width=190 height=30 align=right> " & RSA.Fields
("IP").Value & "</td>"
                        Response.Write "</tr>"
                        rsRegistro.MoveNext
                loop
        end if
end if
%>

Quote:
>-----Original Message-----
>I have a file that queries a MySQL db.  I want to run a
loop to print
>the results.  I know the MySQL line works, butI'm only
getting one
>result (that I know of).  I can only print the first
result.  There
>should be 28 from my query.  Can someone help with making
a loop to
>print ALL the results?  Here's what I have so far:

>    <%
>      DIM SQL
>      DIM RSA()
>      DIM BGC
>      DIM User
>      DIM i

>      txtLastName = Request.Form("txtLastName")

>      if txtLastName = ""  then Response.Redirect
>"getlastname.asp?Action=Blank" end if

>        SQL = "SELECT LName, FName, IP FROM user WHERE
LName = '" &
>txtLastName & "' ORDER BY FName"
>        Set RSA = conn.Execute(SQL,,adCmdText)
>            BGC = "BDBDFF"

>        Response.Write "<tr>"
>        Response.Write "<td bgcolor=" & BGC & "
width=190 height=30
>align=left> " & RSA.Fields("LName").Value & "</td>"
>        Response.Write "<td bgcolor=" & BGC & "
width=190 height=30
>align=left> " & RSA.Fields("FName").Value & "</td>"
>        Response.Write "<td bgcolor=" & BGC & "
width=190 height=30
>align=right> " & RSA.Fields("IP").Value & "</td>"
>        Response.Write "</tr>"

>    %>
>.



Mon, 31 Jan 2005 23:39:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Need help with some ASP SQL query...

2. VBScript and IDC query results - Help - Help - HEEEEELP !!!!!

3. ASP, VBSCRIPT, SQL - need help with one thing

4. How do I print SQL-query results?

5. URGENT: SQL Query help needed!

6. SQL queries, ASP and VBScript

7. Results from an SQL query

8. VBScript- SQL Query of MS SQL 7 Database

9. Help Passing sql query result to VB

10. Help passing sql query result to VB

11. SQL queries on sql results

12. Help Needed on how to Download the Results of Database Query to a File

 

 
Powered by phpBB® Forum Software