loop problem

1. Member
Join Date
Dec 1969
Posts
33

## loop problem

How can use rs1, rs2, rs3, rs4 in a loop ?<BR>I am develop following logic, but I could not<BR>use rs1, r2, rs3 and rs4 in a loop.<BR><BR>sect_area1=Request.Form("sect_area1") <BR>p=Request.Form("p")<BR>sect_area=Request.Form( "sect_area")<BR>u=Request.Form("u")<BR><BR>ssq l = sect_area1+p+sect_area+u<BR><BR>if ssql=sect_area1 then<BR>ssql1="select drawings.date_recd,drawings.date_revd,drawings.dty pe,sectors.sect_area,drawings.name from drawings,sectors <BR> where drawings.name=sectors.name and sectors.sect_area=&#039;"ยง_area1&"&#039;"<BR>end if<BR><BR>if ssql=p then<BR>ssql2="select * from table" <BR>end if<BR><BR>if ssql= sect_Area then<BR>ssql3="select * from table"<BR>end if <BR><BR>if ssql=u then<BR>ssql4="select * from table"<BR>end if<BR><BR>if ssql=ssql1 then <BR>set rs1=cn.Execute(ssql)<BR>end if<BR><BR>if ssql=ssql2 then<BR>set rs2=cn.Execute(ssql2) <BR>end if<BR><BR>if ssql=ssql3 then<BR>set rs3=cn.Execute(ssql3)<BR>end if<BR> <BR>if ssql=ssql4<BR>set rs4=cn.Execute(ssql4) <BR>end if<BR><BR>do while rs.eof=false<BR>Response.Write("&#060;tr&#062;")<B R>fieldData = rs1("date_recd") & ""<BR>If Len(fieldData) = 0 Then fieldData = " - "<BR>Response.Write("&#060;td align=center&#062;" & fieldData & "&#060;/td&#062;")<BR><BR>fieldData = rs1("date_revd") & ""<BR>If Len(fieldData) = 0 Then fieldData = " - "<BR>Response.Write("&#060;td align=center&#062;" & fieldData & "&#060;/td&#062;")<BR><BR>Response.Write("&#060;td&#062;" & rs1("dtype") & "&#060;/td&#062;")<BR>Response.Write("&#060;td&#062;" & rs1("sect_area") & "&#060;/td&#062;")<BR><BR>Response.Write("&#060;td&#062;") <BR>Response.Write("&#060;font face=arial size=2&#062;&#060;a href=" & server.URLEncode(rs1("name")) & "&#062;" & rs1("name") & "&#060;/a&#062;&#060;/font&#062;")<BR>Response.Write("&#060;/td&#062;")<BR><BR>Response.Write("&#060;tr&#062;") <BR>rs.movenext<BR>loop<BR>end if<BR><BR><BR>I have to use different queries.<BR>Please develop above logic so that data will display from the mulitiple queries. <BR>how can use rs1,rs2,rs3 and rs4 in a loop ?<BR><BR>regards.<BR>Mateen<BR>mateenmohd@hotmail. com<BR><BR><BR>

2. Senior Member
Join Date
Dec 1969
Posts
6,476

## RE: loop problem

well for starters lets look at the start of your loop<BR><BR>do while rs.eof=false <BR>Response.Write("&#060;tr&#062;") <BR>fieldData = rs1("date_recd") & "" <BR><BR>You use rs ... Now where have you defined or setup rs as a recordset??<BR>cause I sure dont see it...<BR>Then inside it you refer to rs1 for your values???<BR><BR>Are you trying to determine what table should be queried?<BR>Not much info given...<BR>But if all the possible queries are for the same table<BR>then just use 1 valiable for the query...<BR>something like this<BR><BR>if ssql=p then<BR>sql="select * from table" <BR>end if<BR><BR>if ssql= sect_Area then<BR>sql="select * from table"<BR>end if <BR><BR>if ssql=u then<BR>sql="select * from table"<BR>end if<BR><BR>See it?<BR>come this time what ever your query is will always be in the sql variable<BR>then only 1 execute<BR><BR>set rs=cn.Execute(sql) <BR>do while rs.eof=false<BR><BR>rs.movenext<BR>loop<BR><BR>see what i mean?<BR>im off most of day<BR>so hope this helps.<BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•