grrreg
February 12th, 2001, 09:31
I am having a problem trying to loop through a recordset in ASP. If I hard code the SQL string in it works perfectly but for only one value since its hard coded. When I try it with the variable value (and i did a strcomp to ensure they were exactly the same) it gives me an error, I think it doesn't like the looping with the same recordset. Can anyone see why the recordset wont requery?? The code is below
for l = lBound(id_array) to uBound(id_array)
SQL1 = "exec _Proc_Tunnel @Function = '_Proc_FERecords' , @Action = 'RETRIEVEMENU', @Menu_ID = "
SQL1 = SQL1 + Cstr(id_array(l))
SQL1 = SQL1 + " , @Fid = 0 , @Language_Code = '044' , @User_Id = 'TS' , @User_Uid = 14 , @Popup = '' , @Product_Code = 'DESIGN' , @Period = 'LIVE'"
RS2.Open SQL1,conn2
't= RS2.GetRows
dim id_array2()
t = 40
redim preserve id_array2(t)
z = 0
If Not RS2.EOF Then
RS2.MoveFirst
' Continue until we get to the end of the recordset.
%><SELECT id=drop1 name=drop1>
<OPTION>Select From Sub</OPTION><%
Do While Not RS2.EOF
CID = RS2("Child_ID")
Response.Write("<OPTION>")
Response.Write(RS2("Caption"))
Response.Write("</OPTION>")
id_array2(z) = CID
' Get next record
RS2.MoveNext
z = z + 1
Loop
End if
RS2.Close
next
for l = lBound(id_array) to uBound(id_array)
SQL1 = "exec _Proc_Tunnel @Function = '_Proc_FERecords' , @Action = 'RETRIEVEMENU', @Menu_ID = "
SQL1 = SQL1 + Cstr(id_array(l))
SQL1 = SQL1 + " , @Fid = 0 , @Language_Code = '044' , @User_Id = 'TS' , @User_Uid = 14 , @Popup = '' , @Product_Code = 'DESIGN' , @Period = 'LIVE'"
RS2.Open SQL1,conn2
't= RS2.GetRows
dim id_array2()
t = 40
redim preserve id_array2(t)
z = 0
If Not RS2.EOF Then
RS2.MoveFirst
' Continue until we get to the end of the recordset.
%><SELECT id=drop1 name=drop1>
<OPTION>Select From Sub</OPTION><%
Do While Not RS2.EOF
CID = RS2("Child_ID")
Response.Write("<OPTION>")
Response.Write(RS2("Caption"))
Response.Write("</OPTION>")
id_array2(z) = CID
' Get next record
RS2.MoveNext
z = z + 1
Loop
End if
RS2.Close
next