What I have here is part of a quite hacky Classic ASP (VBscript) script I need to pull data out so I can move it into another source. I am having trouble with it in that it appears to be skipping the first record in the piece it is pulling out. It seems to be fine until it hits a record with only one value, then it seems to pretend it's empty and moves on. If it has more than one record associated it renders them, skipping the first one, and moving on.
This script here shows the categories associated with a listing. (that part is not shown)
<%
If intCategoryID = "" Then
intCategoryID = request("ID")
End If
'Response.Write("Bus ID for Category: " & intCategoryID)
set rstCategories = nothing
intCountComma = 0
intFiveCat = 0
Set rstCategories = Server.CreateObject( "ADODB.Recordset" )
If blnFr = 1 Then
strSQL = "SELECT ID, Case Name_Displayed_L2 When '' Then Name_Displayed Else Name_Displayed_L2 End As Name_Displayed, Attraction_Sub_Types.FriendlyURL"
Else
strSQL = "SELECT ID, Name_Displayed, Attraction_Sub_Types.FriendlyURL"
End If
strSQL = strSQL & " From Attraction_Sub_Types Inner Join Attractions_Attraction_Sub_Types_Link ON Attractions_Attraction_Sub_Types_Link.Sub_TypeID = Attraction_Sub_Types.ID"
strSQL = strSQL & " Where Attractions_Attraction_Sub_Types_Link.AttractionID = '" & intCategoryID & "'"
set rstCategories = Conn.execute(strSQL)
If Not rstCategories.BOF And Not rstCategories.EOF Then
rstCategories.MoveFirst
'Do While (Not rstCategories.EOF AND intFiveCat <= 5 )
Do While (intFiveCat <= 5 )
intFiveCat = intFiveCat + 1
If Not rstCategories.EOF Then
If intCountComma <> 0 Then
strNameDisplayed = rstCategories("Name_Displayed")
strSQL2 = "SELECT ID, Name_Displayed, Attraction_Types.FriendlyURL"
strSQL2 = strSQL2 & " From Attraction_Types Inner Join Attraction_Types_Sub_Types_Link ON Attraction_Types_Sub_Types_Link.TypeID = Attraction_Types.ID"
strSQL2 = strSQL2 & " Where Attraction_Types_Sub_Types_Link.Sub_TypeID = '" & rstCategories("ID") & "'"
set rstMaincats = Conn.execute(strSQL2)
If Not rstMaincats.EOF Then
strMainName = rstMaincats("Name_Displayed")
Else
strMainName = "unsorted"
End If
Response.Write("<td>")
%>
<%=strMainName%>-><%=strNameDisplayed%>
<% Response.Write("</td>")
Else
intCountComma = intCountComma + 1
End If
rstCategories.MoveNext
'Do While ( intFiveCat <= 5 )
'Response.Write("<td>")
'Response.Write("</td>")
'intFiveCat = intFiveCat + 1
'Loop
Else
%>
<td> </td>
<%
End If
Loop
Else
Do While (intFiveCat <= 4 )
intFiveCat = intFiveCat + 1
%>
<td> </td>
<%
Loop
End If
If rstCategories.State = adStateOpen Then
rstCategories.Close
End If
Set rstCategories = Nothing
%>
This image is the output of this piece: http://i.imgur.com/BAwSxWk.jpg you the ones that show blanks, are ones that should have 1 category instead are showing none, while the others are showing the second category and onward.
Thanks in advance.
" & strSQL & "
") to figure out what it tries to run. – Lasse Edsvik Mar 12 '13 at 22:37