...

View Full Version : My db only shows a blank page, why?



Speedy
11-06-2003, 10:35 PM
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



<%@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
%>

oracleguy
11-07-2003, 01:02 AM
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.

jeskel
11-07-2003, 09:22 AM
mmh... weird... maybe try to put a space between your sql statement and the opening of your conn, like that:


rs.open "select * from player order by pos asc", conn

you can also try to make your loop like this:


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...

Roy Sinclair
11-07-2003, 02:38 PM
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:



rs.open "select * from player order by pos asc",conn
if rs.eof then
response.write "<hr />No records found<hr />"
end if
%>

Speedy
11-07-2003, 03:15 PM
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



<%@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
%>

Roy Sinclair
11-07-2003, 03:34 PM
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.

Speedy
11-07-2003, 03:54 PM
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

Roy Sinclair
11-07-2003, 04:16 PM
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):



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:



<%
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.

Speedy
11-07-2003, 04:49 PM
Thanks again Roy,

I really apreciate it

/Speedy



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum