Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

While not ... wend problem... 1

Status
Not open for further replies.

Jahappz

Technical User
Jun 3, 2002
133
SE
What i want to do is to find posts in the table antivirus where foretagskod has a value and to set the variable "task" to 1 . something is wrong with the loop , seems like it goes into an eternity loop...

dbName="Inventering.mdb"
Set conn = Server.CreateObject("ADODB.Connection")

conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " & Server.Mappath(dbName)


Dim SQL, hamta, task
SQL = "SELECT VirusscanID FROM Antivirus WHERE Foretagskod='" & Request.QueryString("id") & " '"
Set hamta=conn.execute(SQL)

while not hamta.EOF
if hamta("VirusscanID")<>"" Then
task = 1
END IF
WEND




 
You're missing a movenext.

while not hamta.EOF
if hamta("VirusscanID")<>"" Then
task = 1
END IF
hamata.Movenext
WEND
 
yep, your looping on the same record over and over, you never tell the recordset to move to the next record:
Code:
while not hamta.EOF
   if hamta("VirusscanID")<>"" Then
      task = 1
   END IF
   [highlight]hamta.MoveNext[/highlight]
WEND

From your code it looks like you are only checking to make sure there is at least one record with a value. If you don't need the data in the recordset later, you could easily embed this into your SQL statement and let the database do the work for you, which will probably be more efficient:
Code:
Dim SQL, hamta, task
SQL = "SELECT VirusscanID FROM Antivirus WHERE Foretagskod='" & Request.QueryString("id") & " ' AND Len(VirusScanID) > 0"
Set hamta=conn.execute(SQL)

If hamta.EOF Then
   task = 0
Else
   task = 1
End If


-Tarwn

barcode_1.gif
 
Thanks for all the good answers!

Feels good to have people that helps! :D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top