webForumDet fria alternativet

Nytt fel med For-loopar. :)

ASP

3 svar · 267 visningar · startad av trexter.com

Medlem sedan apr. 20021 203 inlägg
Frågan#1
	For I=0 to UBound(arrRecords,2)
		strSQL = "SELECT * From Poll_answers WHERE id = " & arrRecords(1,I) & " ORDER BY id DESC"			
		Set RecSet = Connect.Execute(strSQL)
		arrRecords2 = RecSet.GetRows
		RecSet.Close
		Set RecSet = Nothing
		For I=0 to UBound(arrRecords2,2)
			Response.Write arrRecords2(1,I)
		Next
	Next
Microsoft VBScript compilation error '800a0410' 

Invalid 'for' loop control variable 

/v2/other/oldpolls.asp, line 21 

For I=0 to UBound(arrRecords2,2)
-----^

:)

Medlem sedan aug. 20021 752 inlägg
#2

Du använder I i den första loopen, då kan du inte använda den i en loop innuti den loopen. döp om den andra loopens I till ILoop eller någon så ska det fungera.

/Viktor

Medlem sedan apr. 20021 203 inlägg
#3

Tack. Nytt fel:

	For I=0 to UBound(arrRecords,2)
		strSQL = "SELECT * From Poll_answers WHERE id = " & arrRecords(0,I) & " ORDER BY id DESC"
		'Response.Write strSQL
		'Response.End			
		Set RecSet = Connect.Execute(strSQL)
[b]		arrRecords2 = RecSet.GetRows[/b]
		RecSet.Close
		Set RecSet = Nothing
		For ILoop=0 to UBound(arrRecords2,2)
			Response.Write arrRecords2(1,ILoop)
		Next
	Next
ADODB.Recordset error '800a0bcd' 

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. 

/v2/other/oldpolls.asp, line 20

:)

Medlem sedan dec. 200012 464 inlägg
#4

Du måste ha en kontroll om du fick något resultat

For I=0 to UBound(arrRecords,2)
	strSQL = "SELECT * From Poll_answers WHERE id = " & arrRecords(0,I) 
	'Response.Write strSQL
	'Response.End			
	Set RecSet = Connect.Execute(strSQL)
                if  not recset.eof then
	   arrRecords2 = RecSet.GetRows
	   RecSet.Close
	   Set RecSet = Nothing
	   For ILoop=0 to UBound(arrRecords2,2)
		Response.Write arrRecords2(1,ILoop)
	   Next
              end if
Next
259 ms totalt · 4 externa anrop · v20260731065814-full.1dc6f849
115 ms — deklarationer (db)
0 ms — hämta statistik (cache)
129 ms — hämta tråd, inlägg och bilagor (db)
127 ms — ändringar (db)