---
title: "Nytt fel med For-loopar. :)"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/57115-nytt-fel-med-for-loopar"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "trexter.com"
published: "2002-10-25T18:27:56.000Z"
updated: "2002-10-25T19:05:00.000Z"
replies: 3
views: 272
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/57115-nytt-fel-med-for-loopar"
---

# Nytt fel med For-loopar. :)

## #1 — trexter.com, 2002-10-25T18:27Z

```
	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)
-----^
```

 :)

Permalänk: https://www.webforum.nu/p/57115

## #2 — Viktor, 2002-10-25T18:31Z

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

Permalänk: https://www.webforum.nu/p/835039

## #3 — trexter.com, 2002-10-25T18:35Z

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
```

 :)

Permalänk: https://www.webforum.nu/p/835042

## #4 — LarsG, 2002-10-25T19:05Z

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
```

Permalänk: https://www.webforum.nu/p/835065

---

Tråden på webben: https://www.webforum.nu/amne/asp/57115-nytt-fel-med-for-loopar
