I am at a loss, and I'm taking a shot in the dark that someone will either be able to see something I can't see, or point out my error here. The problem is that I'm receiving a recordset that has tens of thousands of records from a query that should only produce 20 records. This normally means that I have some many-to-many (YIKES!) relationship, but that is NOT the case here...
Here is a copy of the query string that in the SQL Server Query Analyzer does produce the 20 record recordset.
When the query executes in my asp page, I try to iterate through it just to see how big it is and the script times out because there are soooooooo many records. Here is a lengthy portion of code just so you can see everything. Please help...
I think that gets the meat of it. FYI, the script times out (depending on what machine I'm on) somewhere between 20,000 and 80,000 iterations of the loop.
thx in advance for any insight
Paul Prewett
Here is a copy of the query string that in the SQL Server Query Analyzer does produce the 20 record recordset.
Code:
SELECT * FROM voc
LEFT OUTER JOIN demo ON voc.id = demo.id
WHERE ((voc.code1 = 1) OR (voc.code2 = 1) OR (voc.code3 = 1) OR (voc.code4 = 1)) AND (region = 1)
When the query executes in my asp page, I try to iterate through it just to see how big it is and the script times out because there are soooooooo many records. Here is a lengthy portion of code just so you can see everything. Please help...
Code:
dim verbRS, con, strWhereClause, strSQL
set con = server.CreateObject ("ADODB.Connection")
set verbRS = server.CreateObject ("ADODB.Recordset")
con.Open("DSN=thedemo;UID=myUserName;PWD=myPassword")
verbRS.ActiveConnection = con
verbRS.CursorLocation = adUseClient
verbRS.CursorType = adOpenStatic
verbRS.LockType = adLockBatchOptimistic
strSQL = "SELECT * FROM voc LEFT OUTER JOIN demo ON voc.id = demo.id WHERE ((voc.code1 = " & request("initiative") & ") OR (voc.code2 = " & request("initiative") & ") OR (voc.code3 = " & request("initiative") & ") OR (voc.code4 = " & request("initiative") & "))"
strSQL = strSQL & " AND (region = 1)"
verbRS.Open strSQL
verbRS.ActiveConnection = nothing
con.close
'^^^^^^^^^^^^^^^^
response.write("<table>")
dim counter
counter = 1
do while not verbRS.EOF
Response.Write("<tr><td>")
Response.Write(counter)
Response.Write("</td></tr>")
counter = counter + 1
verbRS.MoveNext
loop
response.write("</table>")
I think that gets the meat of it. FYI, the script times out (depending on what machine I'm on) somewhere between 20,000 and 80,000 iterations of the loop.
thx in advance for any insight
Paul Prewett