MattiMan
06-10-2007, 03:21 PM
I've been to two other Forums with this question and no one seems able to help.
This has been driving me up the wall for a couple of weeks. I set out to convert my comic collection check list (geek that I am!) from a static HTML table to a dynamic ASP-generated one.
My intention is that the final result should look like this (achieved statically):
www.thestoryworks.com/publishing/comics/collecting/wants63.htm
but it currently looks like this:
www.tmcreative.co.uk/db/buildtable03a_orig_fix.asp
The code I've created looks like this:
<%
Option Explicit
Dim strConnect
%>
<!-- #include file="admin/connect_local.asp" -->
<!-- METADATA TYPE="typelib"
FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<HTML>
<HEAD>
<title>TheStoryWorks.com :: Comics :: Collecting :: Marvel 1963</title>
<link href="style.css" rel="stylesheet" type="text/css">
</pre></HEAD>
<BODY>
<%
Dim objCommand, objRS, varCounter, varMonthCount, varMonthCount10, varLoop, num, tName
Set objCommand = Server.CreateObject("ADODB.Command")
objCommand.ActiveConnection = strConnect
objCommand.CommandText = "SELECT Title.titleName, Item.issue, Item.month, Item.year, Item.have " & _
"FROM Title INNER JOIN Item ON Title.idTitle = Item.idTitle " & _
"WHERE (Item.year LIKE '63') ORDER BY titleName,month;"
objCommand.CommandType = adCmdText
Set objRS = objCommand.Execute
Set objCommand = Nothing
varMonthCount = 1
varMonthCount10 = 10
Response.Write "<table width='100%' border='0' cellspacing='0' cellpadding='2'>"
Response.Write "<tr bgcolor='cccccc'><td class='bold'>Date Published</td>"
For varCounter = 1 to 9
Response.Write "<td class='bold'>0" & varMonthCount & "/" & objRS("year") & "</td>"
varMonthCount = varMonthCount + 1
Next
For varCounter = 10 to 12
Response.Write "<td class='bold'>" & varMonthCount10 & "/" & objRS("year") & "</td>"
varMonthCount10 = varMonthCount10 + 1
Next
Response.Write "<tr>"
For varCounter = 1 to 13
Response.Write "<td> </td>"
Next
Response.Write "</tr>"
' RENDER BODY OF TABLE
num = 0
Do While Not objRS.EOF
Response.Write "<tr"
' WE WANT ALTERNATING ROWS, GREY AND WHITE, SO WE USE THE
' NUM VARIABLE TO TELL US WHAT COLOUR TO MAKE EACH TABLE ROW...
if num mod 2 = 0 then Response.Write " bgcolor=#ffffff" Else Response.Write " bgcolor=#cccccc"
if num <> 0 then
end if
Response.Write "><td class='bold'>" & objRS("titleName") & "</td>"
' BEGIN TO RENDER THE ISSUE NUMBERS
varloop = 1
For varloop = 1 to 12
If objRS("month") <> varLoop then ' IS THE ISSUE IN THE RIGHT COLUMN?
Response.Write "<td align='center'>-</td>"
Else
Response.Write "<td align='center'>" & objRS("issue") & "</td>" ' IF SO, RENDER THE ISSUE NUMBER
'objRS.MoveNext ' MOVE TO THE NEXT ROW
End If
Next ' GO ROUND THE LOOP AGAIN
Response.Write "</tr>"
num = num + 1
objRS.MoveNext ' EMERGENCY MOVENEXT
Loop
objRS.Close
Set objRS = Nothing
%>
</table>
</BODY>
</HTML>
The first objRS.MoveNext (currently commented out) is where I thought the command to move to the next row of the database SHOULD be, but when it's uncommented, I get an Exception error message.
By having the objRS.MoveNext just before the Loop, then at least the required data from the Access DB displays, but it displays incorrectly, placing each issue of a Comic Title on a separate line.
It SHOULD be placing all the issues of say, Amazing Spider-Man, for that year on a single row.
My question is: Why can I not put the objRS.MoveNext as part of an If...Then conditional command right after I've rendered the issue number in the For...Next loop?
(Really perceptive coders will also see another problem looming: How will the code handle the row change when there is no issue of a title published in December? I wish I knew ...)
Best,
Mattiman
This has been driving me up the wall for a couple of weeks. I set out to convert my comic collection check list (geek that I am!) from a static HTML table to a dynamic ASP-generated one.
My intention is that the final result should look like this (achieved statically):
www.thestoryworks.com/publishing/comics/collecting/wants63.htm
but it currently looks like this:
www.tmcreative.co.uk/db/buildtable03a_orig_fix.asp
The code I've created looks like this:
<%
Option Explicit
Dim strConnect
%>
<!-- #include file="admin/connect_local.asp" -->
<!-- METADATA TYPE="typelib"
FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<HTML>
<HEAD>
<title>TheStoryWorks.com :: Comics :: Collecting :: Marvel 1963</title>
<link href="style.css" rel="stylesheet" type="text/css">
</pre></HEAD>
<BODY>
<%
Dim objCommand, objRS, varCounter, varMonthCount, varMonthCount10, varLoop, num, tName
Set objCommand = Server.CreateObject("ADODB.Command")
objCommand.ActiveConnection = strConnect
objCommand.CommandText = "SELECT Title.titleName, Item.issue, Item.month, Item.year, Item.have " & _
"FROM Title INNER JOIN Item ON Title.idTitle = Item.idTitle " & _
"WHERE (Item.year LIKE '63') ORDER BY titleName,month;"
objCommand.CommandType = adCmdText
Set objRS = objCommand.Execute
Set objCommand = Nothing
varMonthCount = 1
varMonthCount10 = 10
Response.Write "<table width='100%' border='0' cellspacing='0' cellpadding='2'>"
Response.Write "<tr bgcolor='cccccc'><td class='bold'>Date Published</td>"
For varCounter = 1 to 9
Response.Write "<td class='bold'>0" & varMonthCount & "/" & objRS("year") & "</td>"
varMonthCount = varMonthCount + 1
Next
For varCounter = 10 to 12
Response.Write "<td class='bold'>" & varMonthCount10 & "/" & objRS("year") & "</td>"
varMonthCount10 = varMonthCount10 + 1
Next
Response.Write "<tr>"
For varCounter = 1 to 13
Response.Write "<td> </td>"
Next
Response.Write "</tr>"
' RENDER BODY OF TABLE
num = 0
Do While Not objRS.EOF
Response.Write "<tr"
' WE WANT ALTERNATING ROWS, GREY AND WHITE, SO WE USE THE
' NUM VARIABLE TO TELL US WHAT COLOUR TO MAKE EACH TABLE ROW...
if num mod 2 = 0 then Response.Write " bgcolor=#ffffff" Else Response.Write " bgcolor=#cccccc"
if num <> 0 then
end if
Response.Write "><td class='bold'>" & objRS("titleName") & "</td>"
' BEGIN TO RENDER THE ISSUE NUMBERS
varloop = 1
For varloop = 1 to 12
If objRS("month") <> varLoop then ' IS THE ISSUE IN THE RIGHT COLUMN?
Response.Write "<td align='center'>-</td>"
Else
Response.Write "<td align='center'>" & objRS("issue") & "</td>" ' IF SO, RENDER THE ISSUE NUMBER
'objRS.MoveNext ' MOVE TO THE NEXT ROW
End If
Next ' GO ROUND THE LOOP AGAIN
Response.Write "</tr>"
num = num + 1
objRS.MoveNext ' EMERGENCY MOVENEXT
Loop
objRS.Close
Set objRS = Nothing
%>
</table>
</BODY>
</HTML>
The first objRS.MoveNext (currently commented out) is where I thought the command to move to the next row of the database SHOULD be, but when it's uncommented, I get an Exception error message.
By having the objRS.MoveNext just before the Loop, then at least the required data from the Access DB displays, but it displays incorrectly, placing each issue of a Comic Title on a separate line.
It SHOULD be placing all the issues of say, Amazing Spider-Man, for that year on a single row.
My question is: Why can I not put the objRS.MoveNext as part of an If...Then conditional command right after I've rendered the issue number in the For...Next loop?
(Really perceptive coders will also see another problem looming: How will the code handle the row change when there is no issue of a title published in December? I wish I knew ...)
Best,
Mattiman