Vælg en tilfældig post - vælg derefter en anden tilfældig
HejsaJeg har et større problem med udvælgelsen af tilfældige poster.
Det foregår over 2 gange.
Første gang er der ikke nogen problemer, men anden gang hvor jeg vil vælge fra samme tabel men ikke samme post som første valgte får jeg en gang imellem følgende fejl:
ADODB.Field error '80020009'
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/scan_web/startside.asp, line 0
Første gang jeg vælger en tilfældig post gør jeg sådan her:
<%
strSQL1 = "SELECT COUNT(*) AS Antal FROM Film WHERE Spotlight='on' AND Godkendt='on'"
Set rs = Connect.Execute(strSQL1)
spotSQL = "SELECT * FROM Film,Filmpopup WHERE ((Film.Godkendt='on') AND (Film.Spotlight='on') AND (Filmpopup.Edbnr=Film.Edbnr)) ORDER BY Filmpopup.Filmnr DESC"
Set spotRS = Connect.Execute(spotSQL)
%>
<table width="188" border="0" cellspacing="0" cellpadding="0" height="460">
<tr>
<td height="24" width="188"><img src="grafik/spotlights.jpg" height="21"><img src="grafik/pilehojre.jpg" width="13" height="21"></td>
</tr>
<tr>
<%
Randomize
RandNum1 = Int(Rnd*rs("Antal"))+1
If not spotRS.bof Then
spotRS.movefirst
spotRS.Move RandNum1-1
%>
<td align="left" valign="top" height="218" width="188" style="border-top:1px #6C717B solid;border-bottom:1px #6C717B solid;border-right:1px #6C717B solid;border-left:1px #6C717B solid;" bgcolor="9FA4AC">
<%
For i = 1 to 1
%>
<a href="moviespot.asp?edbnr=<%=spotRS("Edbnr")%>"><img src="images/film/<%=spotRS("Filmnr")%>/<%=spotRS("Spotpic")%>" width="180" height="208" vspace="7" hspace="7" border="0"></a>
<%
Next
%>
</td>
<%
End if
%>
Anden gang gør jeg sådan her:
<%
strSQL2 = "SELECT COUNT(*) AS Antal FROM Film WHERE Spotlight='on' AND Godkendt='on'"
Set rs1 = Connect.Execute(strSQL2)
spotSQL1 = "SELECT * FROM Film,Filmpopup WHERE ((Film.Godkendt='on') AND (Film.Spotlight='on') AND (Filmpopup.Edbnr=Film.Edbnr) AND (Film.Edbnr <>"&spotRS("Edbnr")&")) ORDER BY Filmpopup.Filmnr DESC"
Set spotRS1 = Connect.Execute(spotSQL1)
%>
<table width="190" border="0" cellspacing="0" cellpadding="0" height="465">
<tr>
<td height="24"><img src="grafik/pilehojre.jpg" width="13" height="21"></td>
</tr>
<tr>
<%
Randomize
RandNum2 = Int(Rnd*rs1("Antal"))+1
If not (spotRS1.bof or spotRS1.eof) Then
spotRS1.movefirst
spotRS1.Move RandNum2+1
%>
<td align="left" valign="top" height="218" width="190" style="border-top:1px #6C717B solid;border-bottom:1px #6C717B solid;border-right:1px #6C717B solid;border-left:1px #6C717B solid;" bgcolor="9FA4AC">
<%
For i = 2 to 2
%>
<a href="moviespot.asp?edbnr=<%=spotRS1("Edbnr")%>"><img src="images/film/<%=spotRS1("Filmnr")%>/<%=spotRS1("Spotpic")%>" width="180" height="208" vspace="7" hspace="7" border="0"></a>
<%
Next
%>
</td>
<%
Else
spotRS1.movefirst
spotRS1.Move RandNum2-1
%>
<td align="left" valign="top" height="218" width="190" style="border-top:1px #6C717B solid;border-bottom:1px #6C717B solid;border-right:1px #6C717B solid;border-left:1px #6C717B solid;" bgcolor="9FA4AC">
<%
For i = 2 to 2
%>
<a href="moviespot.asp?edbnr=<%=spotRS1("Edbnr")%>"><img src="images/film/<%=spotRS1("Filmnr")%>/<%=spotRS1("Spotpic")%>" width="180" height="208" vspace="7" hspace="7" border="0"></a>
<%
Next
%>
</td>
<%
End if
%>
Det går galt i min anden random-select.
