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 9 of 9
  1. #1
    Regular Coder
    Join Date
    May 2003
    Location
    Stockholm, Sweden
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    My db only shows a blank page, why?

    Hi,

    I have an Access Database with the following info:

    tournament.mdb (I have 3 posts in the db)
    player (Table)
    ID = Primary Key
    Fname = First Name
    Lname = Last Name
    hcp = handicap
    r1 - r5 = round 1 - round 5
    Total = The Amount of r1 - r5
    Pos = Position

    What I wanna know is what I have missed or done wrong
    in the following code because I only get a blank page
    when I load it?!

    Thanks in advance, Speedy

    Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    
    <%
    set conn=Server.CreateObject("ADODB.Connection")
    conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("db\tournament.mdb")
    set rs=Server.CreateObject("ADODB.recordset")
    
    rs.open "select * from player order by pos asc",conn
    %>
    
    <center>
    <table border="0" width="260">
    <%do while not rs.eof %>
    <tr>
    <td align="center"><%=rs("pos")%></td>
    <td align="left"><%=rs("Fname")%>&nbsp;<%=rs("Lname")%></td>
    <td align="center"><%=rs("hcp")%></td>
    <td align="center"><%=rs("r1")%></td>
    <td align="center"><%=rs("r2")%></td>
    <td align="center"><%=rs("r3")%></td>
    <td align="center"><%=rs("r4")%></td>
    <td align="center"><%=rs("r5")%></td>
    <td align="right"><%=rs("total")%></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td align="center"><%=rs("pos")%></td>
    <td align="left"><%=rs("Fname")%>&nbsp;<%=rs("Lname")%></td>
    <td align="center"><%=rs("hcp")%></td>
    <td align="center"><%=rs("r1")%></td>
    <td align="center"><%=rs("r2")%></td>
    <td align="center"><%=rs("r3")%></td>
    <td align="center"><%=rs("r4")%></td>
    <td align="center"><%=rs("r5")%></td>
    <td align="right"><%=rs("total")%></td>
    </tr>
    <%rs.movenext
    Loop%>
    </table>
    
    </center>
    
    </body>
    </html>
    <%
    set rs = nothing
    %>

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Well, first you can correctly call your recordset fields, instead of:
    rs("pos")
    it should be:
    rs.Fields("pos").Value

    That speeds up the response time and prevents errors.

    Dunno if that will resolve your problem or not though.
    OracleGuy

  • #3
    Regular Coder
    Join Date
    Aug 2003
    Posts
    565
    Thanks
    0
    Thanked 0 Times in 0 Posts
    mmh... weird... maybe try to put a space between your sql statement and the opening of your conn, like that:
    Code:
    rs.open "select * from player order by pos asc", conn
    you can also try to make your loop like this:
    Code:
    while not rs.EOF
    ...
    rs.MoveNext
    wend
    I would add that you don't need the "asc" in your actual sql statement since it will be like that anyways... It's usually used when you use DESC in your request to dissociate ways of displaying data...

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would suggest that the reason you get a blank page is because you're getting no records in your recordset.

    Add the red code below:

    Code:
    rs.open "select * from player order by pos asc",conn
    if rs.eof then
        response.write "<hr />No records found<hr />"
    end if
    %>
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #5
    Regular Coder
    Join Date
    May 2003
    Location
    Stockholm, Sweden
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi again,

    First of all I wanna thank you for all the answers but it
    didn't really help :(.

    Roy was right about there was no records in the recordset
    I don't know why though because I have 3 posts in my
    database?

    I did change all the things you suggested me to but one thing,
    and that was bouchels [wend] thingy because that gave me an
    error mess. It was probably me who didn't get how it was
    supposed to be coded?!

    The code looks like this now, see anything else that could be
    wrong?

    /Speedy

    Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    
    <%
    set conn=Server.CreateObject("ADODB.Connection")
    conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("db\tournament.mdb")
    set rs=Server.CreateObject("ADODB.recordset")
    
    rs.open "select * from player order by pos", conn
    if rs.eof then
        response.write "<hr><center>No records found</center><hr>"
    end if
    %>
    
    <center>
    <table border="0" width="260">
    <%do while not rs.eof %>
    <tr>
    <td align="center"><%=rs.Fields("pos").Value%></td>
    <td align="left"><%=rs.Fields("Fname").Value%>&nbsp;<%=rs.Fields("Lname").Value%></td>
    <td align="center"><%=rs.Fields("hcp").Value%></td>
    <td align="center"><%=rs.Fields("r1").Value%></td>
    <td align="center"><%=rs.Fields("r2").Value%></td>
    <td align="center"><%=rs.Fields("r3").Value%></td>
    <td align="center"><%=rs.Fields("r4").Value%></td>
    <td align="center"><%=rs.Fields("r5").Value%></td>
    <td align="right"><%=rs.Fields("total").Value%></td>
    </tr>
    <tr bgcolor="#CCCCCC">
    <td align="center"><%=rs.Fields("pos").Value%></td>
    <td align="left"><%=rs.Fields("Fname").Value%>&nbsp;<%=rs.Fields("Lname").Value%></td>
    <td align="center"><%=rs.Fields("hcp").Value%></td>
    <td align="center"><%=rs.Fields("r1").Value%></td>
    <td align="center"><%=rs.Fields("r2").Value%></td>
    <td align="center"><%=rs.Fields("r3").Value%></td>
    <td align="center"><%=rs.Fields("r4").Value%></td>
    <td align="center"><%=rs.Fields("r5").Value%></td>
    <td align="right"><%=rs.Fields("total").Value%></td>
    </tr>
    <%rs.movenext
    Loop%>
    </table>
    
    </center>
    
    </body>
    </html>
    <%
    set rs = nothing
    %>
    Last edited by Speedy; 11-07-2003 at 04:46 PM.

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No records in the recordset means there's a problem with the select (or you're selecting from an empty table). Since you say there's three records in that table, the first thing I'd try is a slight alteration of the select.

    select * from [player] order by [pos]

    The [ and ] characters are useful for making sure you haven't accidentaly used a reserved word. I don't know that this will make a difference but it's easy enough to try.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #7
    Regular Coder
    Join Date
    May 2003
    Location
    Stockholm, Sweden
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Roy,

    it works fine now but I wonder if you can tell me another thing
    to?
    (or just tell me if you think I should start a new thread for this question)

    In the code I have 2 rows in my table, the 1st with white as background and the 2nd with a grey background, I thought
    that this would make every other row grey and it did but
    it looks like this:

    1 Fname Lname hcp r1 r2 r3 r4 r5 total (white bg)
    1 Fname Lname hcp r1 r2 r3 r4 r5 total (grey bg)
    2 Fname Lname hcp r1 r2 r3 r4 r5 total (white bg)
    2 Fname Lname hcp r1 r2 r3 r4 r5 total (grey bg)
    3 Fname Lname hcp r1 r2 r3 r4 r5 total (white bg)
    3 Fname Lname hcp r1 r2 r3 r4 r5 total (grey bg)

    but I wanted it to be like this:

    1 Fname Lname hcp r1 r2 r3 r4 r5 total (white bg)
    2 Fname Lname hcp r1 r2 r3 r4 r5 total (grey bg)
    3 Fname Lname hcp r1 r2 r3 r4 r5 total (white bg)

    what did I do wrong??

    /Speedy

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The reason you get each record with both the white and gray background colors is because your code explicitly writes a table row with the white background and then follows up by writiing the same record from the recordset with the gray background.

    You should define a string with the background color before you enter your loop (start it with the value of the gray color):

    Code:
    dim background
    background="#cccccc"
    Then just before you write the row tag you check set the color to it's opposite and then write the color with the tag:

    Code:
    <%
    if background = "#ffffff" then
        background = "#cccccc"
    else
        background = "#ffffff"
    end if
    %>
    <tr bgcolor="<%=background%>>
    Also make sure you get rid of the code that writes the same row the second time.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #9
    Regular Coder
    Join Date
    May 2003
    Location
    Stockholm, Sweden
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks again Roy,

    I really apreciate it

    /Speedy


  •  

    Posting Permissions

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