Cerixus
asked on
vbscript step through SQL results
The attached code properly displays the message box for the first record that matches the criteria, however it then just repeats the messagebox for the same record indefinitely. I've used a similar setup before, but it was ASP. This is straight VBS and I must be missing something simple.
counter = 0
limit = 5
Dim cConnection
Set cConnection = CreateObject("ADODB.Connection")
//setting variables here for connection string, username, password.
cConnection.Open DBConString,DBUser,DBPass
SQLstmt = "SELECT field1, field2 from Table1 WHERE Field1 IS NULL"
Set RS = cConnection.Execute(SQLstmt)
while (not RS.EOF) AND (counter < limit)
msgbox("Field1: " & RS.Fields.Item("field1").value)
//do other stuff
counter = counter + 1
RS.Movenext()
wend
ASKER
No, it's apparently because I'm using ADODB.Connection and need to define and use a recordset... though I'm not entirely sure how to get to that point using a DSNless connection.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Maybe just make it RS.MoveNext without the parentheses ?