Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBScript - not extracting data from database

    Hi again,

    I tried the below code and have a valid 'countrydb.mdb' database. But after running this, all it returns is 'Country..... City..... Currency..... Population' and nothing else. It should be displaying the country name, city etc.

    Can you tell me why??? Pleasee...

    Thanks a lot guys!


    <% @language = VBScript %>
    <head>
    <TITLE>ASP - Country Query</TITLE>
    <body>
    <%
    Dim MyConn, MydbFilePath
    Set MyConn = Server.CreateObject("ADODB.Connection")
    MydbFilePath = Server.MapPath("countrydb.mdb")

    MyConn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & MydbFilePath & ";"
    query1 = "SELECT * FROM Countrytbl"
    Set RS = MyConn.Execute(query1)
    %>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


    Country..... City..... Currency..... Population<br><br>
    <ul>
    <%
    WHILE NOT RS.EOF
    %>

    <li>
    <% =RS("Country") %> .....
    <% =RS("City") %> .....
    <% =RS("Currency") %> .....
    <% =RS("Population") %>
    </li>
    <%
    RS.MoveNext
    WEND
    %>
    </ul>
    </body>
    </head>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,869
    Thanks
    79
    Thanked 4,421 Times in 4,386 Posts
    Add in a couple of lines:
    Code:
    Set RS = MyConn.Execute(query1)
    If RS.EOF Then 
        Response.Write "No records returned from query: " & query1 & "<hr>"
    End If
    ...
    What happens?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •