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):
but it currently looks like this:
The code I've created looks like this:
[code]<%<br />Option Explicit
TheStoryWorks.com :: Comics :: Collecting :: Marvel 1963
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 "
For varCounter = 1 to 9 Response.Write "0" & varMonthCount & "/" & objRS("year") & "" varMonthCount = varMonthCount + 1 Next For varCounter = 10 to 12 Response.Write "" & varMonthCount10 & "/" & objRS("year") & "" varMonthCount10 = varMonthCount10 + 1 Next Response.Write "
" For varCounter = 1 to 13 Response.Write " " Next Response.Write "" ' RENDER BODY OF TABLEnum = 0 Do While Not objRS.EOF Response.Write "
' 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 ">" & objRS("titleName") & ""' 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 "-" Else Response.Write "" & objRS("issue") & "" ' IF SO, RENDER THE ISSUE NUMBER 'objRS.MoveNext ' MOVE TO THE NEXT ROW End If Next ' GO ROUND THE LOOP AGAIN Response.Write "" num = num + 1 objRS.MoveNext ' EMERGENCY MOVENEXTLoop objRS.CloseSet objRS = Nothing%>
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 ...)