looping
I'm trying to build a daily schedule that shows available and unavailable
times on a particular day based on a queryString upon entering the page.
Is it possible to have 2 looping functions on the same page? Right now I
have:
<%
i=i
Do Until rstTimes.EOF
%>
*** I NEED ANOTHER RECORDSET TO LOOP IN HERE ***
<%
i=i+1
rstTimes.Movenext
Loop
%>
If someone has any ideas or would like to see more of the page I can give
more details. Any help would be greatly appreciated. I'm a little behind
on this now.
[587 byte] By [
kyle] at [2007-11-9 17:50:22]

# 1 Re: looping
Sure, it's possible. But it can be time-costly, and may not be
necessary.
If you're going to loop over the same records each time, you could
create that second recordset outside the loop and put it into an array
using GetRows(). Then you could just loop over the array inside the
recordset loop. Depending on the size of the recordsets, this could
give you a significant speed boost. More on GetRows here (this is
obviously one of his pet peeves, but it's got good examples):
http://www.learnasp.com/advice/whygetrows.asp
If you need to get new data for each iteration through the outer loop,
you might think about combining the data into 1 recordset, to speed
things up. If that's not possible, the syntax you're looking for is:
do until rstTimes.EOF
nInnerLoopID = rstTimes("someID")
sSQL = "Select somedata from sometable where id = " & nInnerLoopID
set rsInnerLoop = Conn.Execute(sSQL)
do until rsInnerLoop.EOF
sSomeData = rsInnerLoop("somedata")
dosomethingwith(sSomeData)
rsInnerLoop.MoveNext
loop
rstTimes.MoveNext
loop
"kyle" <kfinch@bayoucitygroup.com> wrote in message
news:3ed367cf$1@tnews.web.dev-archive.com...
>
> I'm trying to build a daily schedule that shows available and
unavailable
> times on a particular day based on a queryString upon entering the
page.
> Is it possible to have 2 looping functions on the same page? Right now
I
> have:
> <%
> i=i
> Do Until rstTimes.EOF
> %>
> *** I NEED ANOTHER RECORDSET TO LOOP IN HERE ***
> <%
> i=i+1
> rstTimes.Movenext
> Loop
> %>
> If someone has any ideas or would like to see more of the page I can
give
> more details. Any help would be greatly appreciated. I'm a little
behind
> on this now.
# 2 Re: looping
Thanks Kris
Can I tell you a little more about what I'm trying to do? I'm still getting
an error. I can tell it's trying to work, but not quite there. You can email
me directly if you like.
"Kris Eiben" <eibenkthisisforspammers@yahoo.com> wrote:
>Sure, it's possible. But it can be time-costly, and may not be
>necessary.
>
>If you're going to loop over the same records each time, you could
>create that second recordset outside the loop and put it into an array
>using GetRows(). Then you could just loop over the array inside the
>recordset loop. Depending on the size of the recordsets, this could
>give you a significant speed boost. More on GetRows here (this is
>obviously one of his pet peeves, but it's got good examples):
>http://www.learnasp.com/advice/whygetrows.asp
>
>If you need to get new data for each iteration through the outer loop,
>you might think about combining the data into 1 recordset, to speed
>things up. If that's not possible, the syntax you're looking for is:
>do until rstTimes.EOF
> nInnerLoopID = rstTimes("someID")
> sSQL = "Select somedata from sometable where id = " & nInnerLoopID
> set rsInnerLoop = Conn.Execute(sSQL)
> do until rsInnerLoop.EOF
> sSomeData = rsInnerLoop("somedata")
> dosomethingwith(sSomeData)
> rsInnerLoop.MoveNext
> loop
> rstTimes.MoveNext
>loop
>
>"kyle" <kfinch@bayoucitygroup.com> wrote in message
>news:3ed367cf$1@tnews.web.dev-archive.com...
>>
>> I'm trying to build a daily schedule that shows available and
>unavailable
>> times on a particular day based on a queryString upon entering the
>page.
>> Is it possible to have 2 looping functions on the same page? Right now
>I
>> have:
>> <%
>> i=i
>> Do Until rstTimes.EOF
>> %>
>> *** I NEED ANOTHER RECORDSET TO LOOP IN HERE ***
>> <%
>> i=i+1
>> rstTimes.Movenext
>> Loop
>> %>
>> If someone has any ideas or would like to see more of the page I can
>give
>> more details. Any help would be greatly appreciated. I'm a little
>behind
>> on this now.
>
>
Kyle at 2007-11-11 23:17:54 >

# 3 Re: looping
PLEASE keep it in the newsgroup. (The email address I use here is a
spam trap.) What do you have?
"Kyle" <kfinch@bayoucitygroup.com> wrote in message
news:3ed39435$1@tnews.web.dev-archive.com...
>
> Thanks Kris
> Can I tell you a little more about what I'm trying to do? I'm still
getting
> an error. I can tell it's trying to work, but not quite there. You can
email
> me directly if you like.
>
>
> "Kris Eiben" <eibenkthisisforspammers@yahoo.com> wrote:
> >Sure, it's possible. But it can be time-costly, and may not be
> >necessary.
> >
> >If you're going to loop over the same records each time, you could
> >create that second recordset outside the loop and put it into an
array
> >using GetRows(). Then you could just loop over the array inside the
> >recordset loop. Depending on the size of the recordsets, this could
> >give you a significant speed boost. More on GetRows here (this is
> >obviously one of his pet peeves, but it's got good examples):
> >http://www.learnasp.com/advice/whygetrows.asp
> >
> >If you need to get new data for each iteration through the outer
loop,
> >you might think about combining the data into 1 recordset, to speed
> >things up. If that's not possible, the syntax you're looking for is:
> >do until rstTimes.EOF
> > nInnerLoopID = rstTimes("someID")
> > sSQL = "Select somedata from sometable where id = " &
nInnerLoopID
> > set rsInnerLoop = Conn.Execute(sSQL)
> > do until rsInnerLoop.EOF
> > sSomeData = rsInnerLoop("somedata")
> > dosomethingwith(sSomeData)
> > rsInnerLoop.MoveNext
> > loop
> > rstTimes.MoveNext
> >loop
> >
> >"kyle" <kfinch@bayoucitygroup.com> wrote in message
> >news:3ed367cf$1@tnews.web.dev-archive.com...
> >>
> >> I'm trying to build a daily schedule that shows available and
> >unavailable
> >> times on a particular day based on a queryString upon entering the
> >page.
> >> Is it possible to have 2 looping functions on the same page? Right
now
> >I
> >> have:
> >> <%
> >> i=i
> >> Do Until rstTimes.EOF
> >> %>
> >> *** I NEED ANOTHER RECORDSET TO LOOP IN HERE ***
> >> <%
> >> i=i+1
> >> rstTimes.Movenext
> >> Loop
> >> %>
> >> If someone has any ideas or would like to see more of the page I
can
> >give
> >> more details. Any help would be greatly appreciated. I'm a little
> >behind
> >> on this now.
# 4 Re: looping
Thanks for your help Kris. I've got a lot here.
FIRST MY QUERYSTRING:
.../daily.asp?queryDay=Monday&queryDate=06/02/2003
***THE SCRIPT ON THE PAGE ENTERED:
Dim DBConn, rstTimes, rstTimeCheck, strSQL1, strSQL2, TheMessage1, i
If isEmpty(Request.QueryString("queryDate")) Then
Response.Redirect "./month_selection.asp?queryDate=NULL"
Else
Set DBConn = Server.CreateObject ("ADODB.Connection")
DBConn.Open "Provider=SQLOLEDB; Data Source=OPERATIONS-01;" & _
"Initial Catalog=######;UId=######;pwd=######;"
' GET ALL TIMES FOR PARTICULAR DAY
Set rstTimes = Server.CreateObject("ADODB.Recordset")
strSQL1 = ("SELECT * FROM DaysAndTimes WHERE " _
& "TODAY = '" & (Request.QueryString("queryDay")) & "'")
rstTimes.Open strSQL1, DBConn
' COMPARE ALL TIMES TO SCHEDULED APPOINTMENT TIMES
Set rstTimeCheck = Server.CreateObject("ADODB.Recordset")
strSQL2 = ("SELECT IsOkay FROM AppDetails WHERE " _
& "AppTime = '" & (rstTimes("AvailableTime")) & "' AND " _
& "AppDate = '" & (Request.QueryString("queryDate")) & "'")
rstTimeCheck.Open strSQL2, DBConn
' SHOW TIMES AS "UNAVAILABLE" IF TAKEN
If (rstTimeCheck("IsOkay")) = "UA" Then
TheMessage1 = "--TIME UNAVAILABLE--"
Else
TheMessage1 = " "
End If
End If
***I'M WANTING MY TABLE TO SHOW AVAILABLE AND UNAVAILABLE TIMES BASED ON
rstTimeCheck("IsOkay")
***HERE IS THE TABLE
<%
i=i
do until rstTimes.EOF
%>
<form method="post" id="form1" name="form1"><TR>
<% If (rstTimeCheck("IsOkay")) = "UA" Then %>
<TD width="75" align="middle" height="30"><% Response.Write rstTimes("AvailableTime")
%></TD>
<TD width="450" height="30"><% Response.Write TheMessage1%>
<!-- IF REQUESTED TIME IN UNAVAILABLE -->
<% Else %><TD width="75" align="middle" height="30"><% Response.Write rstTimes("AvailableTime")
%></TD>
<TD width="450" height="30"><INPUT id="Text1" type="text" name="Text1">
<IMG height="1" src="i/clear.gif" width="20">
<IMG height="1" src="i/clear.gif" width="15"> <INPUT id="Submit1" type="submit"
value="Submit" name="Submit1">
<IMG height="1" src="i/clear.gif" width="20">SELECT THIS TIME </TD>
<% End If %></TD>
</TR></form>
<%
rstTimes.MoveNext
loop
%>
***RIGHT NOW THE WAY I HAVE THIS WRITTEN IT DOES NOT DIFFERENTIATE BASED
ON rstTimeCheck("IsOkay")
"Kris Eiben" <eibenkthisisforspammers@yahoo.com> wrote:
>PLEASE keep it in the newsgroup. (The email address I use here is a
>spam trap.) What do you have?
>
>"Kyle" <kfinch@bayoucitygroup.com> wrote in message
>news:3ed39435$1@tnews.web.dev-archive.com...
>>
>> Thanks Kris
>> Can I tell you a little more about what I'm trying to do? I'm still
>getting
>> an error. I can tell it's trying to work, but not quite there. You can
>email
>> me directly if you like.
>>
>>
>> "Kris Eiben" <eibenkthisisforspammers@yahoo.com> wrote:
>> >Sure, it's possible. But it can be time-costly, and may not be
>> >necessary.
>> >
>> >If you're going to loop over the same records each time, you could
>> >create that second recordset outside the loop and put it into an
>array
>> >using GetRows(). Then you could just loop over the array inside the
>> >recordset loop. Depending on the size of the recordsets, this could
>> >give you a significant speed boost. More on GetRows here (this is
>> >obviously one of his pet peeves, but it's got good examples):
>> >http://www.learnasp.com/advice/whygetrows.asp
>> >
>> >If you need to get new data for each iteration through the outer
>loop,
>> >you might think about combining the data into 1 recordset, to speed
>> >things up. If that's not possible, the syntax you're looking for is:
>> >do until rstTimes.EOF
>> > nInnerLoopID = rstTimes("someID")
>> > sSQL = "Select somedata from sometable where id = " &
>nInnerLoopID
>> > set rsInnerLoop = Conn.Execute(sSQL)
>> > do until rsInnerLoop.EOF
>> > sSomeData = rsInnerLoop("somedata")
>> > dosomethingwith(sSomeData)
>> > rsInnerLoop.MoveNext
>> > loop
>> > rstTimes.MoveNext
>> >loop
>> >
>> >"kyle" <kfinch@bayoucitygroup.com> wrote in message
>> >news:3ed367cf$1@tnews.web.dev-archive.com...
>> >>
>> >> I'm trying to build a daily schedule that shows available and
>> >unavailable
>> >> times on a particular day based on a queryString upon entering the
>> >page.
>> >> Is it possible to have 2 looping functions on the same page? Right
>now
>> >I
>> >> have:
>> >> <%
>> >> i=i
>> >> Do Until rstTimes.EOF
>> >> %>
>> >> *** I NEED ANOTHER RECORDSET TO LOOP IN HERE ***
>> >> <%
>> >> i=i+1
>> >> rstTimes.Movenext
>> >> Loop
>> >> %>
>> >> If someone has any ideas or would like to see more of the page I
>can
>> >give
>> >> more details. Any help would be greatly appreciated. I'm a little
>> >behind
>> >> on this now.
>
>
Kyle at 2007-11-11 23:19:58 >

# 5 Re: looping
You're not looping over rstTimeCheck at all. Why not combine into one
recordset?
sSQL = "Select dat.AvailableTime, ad.IsOkay" &_
" from DaysAndTimes dat, AppDetails ad" &_
" where dat.AvailableTime = ad.AppTime" &_
" and dat.Today = '" & request.querystring("queryDay") &
"'" &_
" and ad.AppDate = '" & request.querystring("queryDate")
& "'"
"Kyle" <kfinch@bayoucitygroup.com> wrote in message
news:3ed4a710$1@tnews.web.dev-archive.com...
>
> Thanks for your help Kris. I've got a lot here.
> FIRST MY QUERYSTRING:
> ../daily.asp?queryDay=Monday&queryDate=06/02/2003
> ***THE SCRIPT ON THE PAGE ENTERED:
> Dim DBConn, rstTimes, rstTimeCheck, strSQL1, strSQL2, TheMessage1, i
> If isEmpty(Request.QueryString("queryDate")) Then
> Response.Redirect "./month_selection.asp?queryDate=NULL"
> Else
> Set DBConn = Server.CreateObject ("ADODB.Connection")
> DBConn.Open "Provider=SQLOLEDB; Data Source=OPERATIONS-01;" & _
> "Initial Catalog=######;UId=######;pwd=######;"
> ' GET ALL TIMES FOR PARTICULAR DAY
> Set rstTimes = Server.CreateObject("ADODB.Recordset")
> strSQL1 = ("SELECT * FROM DaysAndTimes WHERE " _
> & "TODAY = '" & (Request.QueryString("queryDay")) & "'")
> rstTimes.Open strSQL1, DBConn
> ' COMPARE ALL TIMES TO SCHEDULED APPOINTMENT TIMES
> Set rstTimeCheck = Server.CreateObject("ADODB.Recordset")
> strSQL2 = ("SELECT IsOkay FROM AppDetails WHERE " _
> & "AppTime = '" & (rstTimes("AvailableTime")) & "' AND " _
> & "AppDate = '" & (Request.QueryString("queryDate")) &
"'")
> rstTimeCheck.Open strSQL2, DBConn
> ' SHOW TIMES AS "UNAVAILABLE" IF TAKEN
> If (rstTimeCheck("IsOkay")) = "UA" Then
> TheMessage1 = "--TIME UNAVAILABLE--"
> Else
> TheMessage1 = " "
> End If
> End If
> ***I'M WANTING MY TABLE TO SHOW AVAILABLE AND UNAVAILABLE TIMES BASED
ON
> rstTimeCheck("IsOkay")
> ***HERE IS THE TABLE
> <%
> i=i
> do until rstTimes.EOF
> %>
> <form method="post" id="form1" name="form1"><TR>
> <% If (rstTimeCheck("IsOkay")) = "UA" Then %>
> <TD width="75" align="middle" height="30"><%
Response.Write rstTimes("AvailableTime")
> %></TD>
> <TD width="450" height="30"><% Response.Write
TheMessage1%>
> <!-- IF REQUESTED TIME IN UNAVAILABLE -->
> <% Else %><TD width="75" align="middle" height="30"><%
Response.Write rstTimes("AvailableTime")
> %></TD>
> <TD width="450" height="30"><INPUT id="Text1" type="text"
name="Text1">
> <IMG height="1" src="i/clear.gif" width="20">
> <IMG height="1" src="i/clear.gif" width="15"> <INPUT
id="Submit1" type="submit"
> value="Submit" name="Submit1">
> <IMG height="1" src="i/clear.gif" width="20">SELECT THIS
TIME </TD>
> <% End If %></TD>
> </TR></form>
> <%
> rstTimes.MoveNext
> loop
> %>
> ***RIGHT NOW THE WAY I HAVE THIS WRITTEN IT DOES NOT DIFFERENTIATE
BASED
> ON rstTimeCheck("IsOkay")
>
> "Kris Eiben" <eibenkthisisforspammers@yahoo.com> wrote:
> >PLEASE keep it in the newsgroup. (The email address I use here is a
> >spam trap.) What do you have?
> >
> >"Kyle" <kfinch@bayoucitygroup.com> wrote in message
> >news:3ed39435$1@tnews.web.dev-archive.com...
> >>
> >> Thanks Kris
> >> Can I tell you a little more about what I'm trying to do? I'm still
> >getting
> >> an error. I can tell it's trying to work, but not quite there. You
can
> >email
> >> me directly if you like.
> >>
> >>
> >> "Kris Eiben" <eibenkthisisforspammers@yahoo.com> wrote:
> >> >Sure, it's possible. But it can be time-costly, and may not be
> >> >necessary.
> >> >
> >> >If you're going to loop over the same records each time, you could
> >> >create that second recordset outside the loop and put it into an
> >array
> >> >using GetRows(). Then you could just loop over the array inside
the
> >> >recordset loop. Depending on the size of the recordsets, this
could
> >> >give you a significant speed boost. More on GetRows here (this is
> >> >obviously one of his pet peeves, but it's got good examples):
> >> >http://www.learnasp.com/advice/whygetrows.asp
> >> >
> >> >If you need to get new data for each iteration through the outer
> >loop,
> >> >you might think about combining the data into 1 recordset, to
speed
> >> >things up. If that's not possible, the syntax you're looking for
is:
> >> >do until rstTimes.EOF
> >> > nInnerLoopID = rstTimes("someID")
> >> > sSQL = "Select somedata from sometable where id = " &
> >nInnerLoopID
> >> > set rsInnerLoop = Conn.Execute(sSQL)
> >> > do until rsInnerLoop.EOF
> >> > sSomeData = rsInnerLoop("somedata")
> >> > dosomethingwith(sSomeData)
> >> > rsInnerLoop.MoveNext
> >> > loop
> >> > rstTimes.MoveNext
> >> >loop
> >> >
> >> >"kyle" <kfinch@bayoucitygroup.com> wrote in message
> >> >news:3ed367cf$1@tnews.web.dev-archive.com...
> >> >>
> >> >> I'm trying to build a daily schedule that shows available and
> >> >unavailable
> >> >> times on a particular day based on a queryString upon entering
the
> >> >page.
> >> >> Is it possible to have 2 looping functions on the same page?
Right
> >now
> >> >I
> >> >> have:
> >> >> <%
> >> >> i=i
> >> >> Do Until rstTimes.EOF
> >> >> %>
> >> >> *** I NEED ANOTHER RECORDSET TO LOOP IN HERE ***
> >> >> <%
> >> >> i=i+1
> >> >> rstTimes.Movenext
> >> >> Loop
> >> >> %>
> >> >> If someone has any ideas or would like to see more of the page I
> >can
> >> >give
> >> >> more details. Any help would be greatly appreciated. I'm a
little
> >> >behind
> >> >> on this now.
# 6 Re: looping
Almost perfect Kris. You're helping with my incredible headache.
Now it only shows the times that are unavailable. I'm so close now, but it
has to show all the times. Man, you're going on the Christmas list for helping
me with this. The DaysAndTimes table shows times in thirty minute increments
from 9:00 to 6:00. I need all those to show
********** this is what i have now
Dim DBConn, rstTimes, rstTimeCheck, strSQL, TheMessage1, i
If isEmpty(Request.QueryString("queryDate")) Then
Response.Redirect "./month_selection.asp?queryDate=NULL"
Else
Set DBConn = Server.CreateObject ("ADODB.Connection")
DBConn.Open "Provider=SQLOLEDB; Data Source=OPERATIONS-01;" & _
"Initial Catalog=SierraTherapy;UId=SA;pwd=2121118;"
' GET ALL TIMES FOR PARTICULAR DAY
Set rstTimes = Server.CreateObject("ADODB.Recordset")
strSQL = "Select dat.AvailableTime, ad.IsOkay" &_
" from DaysAndTimes dat, AppDetails ad" &_
" where dat.AvailableTime = ad.AppTime" &_
" and dat.Today = '" & request.querystring("queryDay") & "'" &_
" and ad.AppDate = '" & request.querystring("queryDate") & "'"
rstTimes.Open strSQL, DBConn
' SHOW TIMES AS "UNAVAILABLE" IF TAKEN
If (rstTimes("IsOkay")) = "UA" Then
TheMessage1 = "--TIME UNAVAILABLE--"
End If
End If
<%
i=i
do until rstTimes.EOF
%>
<form method="post" id="form1" name="form1"><TR>
<!-- IF REQUESTED TIME IS UNAVAILABLE -->
<% If Not isEmpty (rstTimes("IsOkay")) Then %>
<TD width="75" align="middle" height="30"><% Response.Write rstTimes("AvailableTime")
%></TD>
<TD width="450" height="30"><% Response.Write TheMessage1%>
<% Else %><TD width="75" align="middle" height="30"><% Response.Write rstTimes("AvailableTime")
%></TD>
<TD width="450" height="30"><INPUT id="Text1" type="text" name="Text1">
<IMG height="1" src="i/clear.gif" width="20">
<IMG height="1" src="i/clear.gif" width="15"> <INPUT id="Submit1" type="submit"
value="Submit" name="Submit1">
<IMG height="1" src="i/clear.gif" width="20">SELECT THIS TIME</TD>
<% End If %></TD>
</TR></form>
<%
rstTimes.MoveNext
loop
%>
**********
"Kris Eiben" <eibenkthisisforspammers@yahoo.com> wrote:
>You're not looping over rstTimeCheck at all. Why not combine into one
>recordset?
>
>sSQL = "Select dat.AvailableTime, ad.IsOkay" &_
> " from DaysAndTimes dat, AppDetails ad" &_
> " where dat.AvailableTime = ad.AppTime" &_
> " and dat.Today = '" & request.querystring("queryDay") &
>"'" &_
> " and ad.AppDate = '" & request.querystring("queryDate")
>& "'"
>
>"Kyle" <kfinch@bayoucitygroup.com> wrote in message
>news:3ed4a710$1@tnews.web.dev-archive.com...
>>
>> Thanks for your help Kris. I've got a lot here.
>> FIRST MY QUERYSTRING:
>> ../daily.asp?queryDay=Monday&queryDate=06/02/2003
>> ***THE SCRIPT ON THE PAGE ENTERED:
>> Dim DBConn, rstTimes, rstTimeCheck, strSQL1, strSQL2, TheMessage1, i
>> If isEmpty(Request.QueryString("queryDate")) Then
> > Response.Redirect "./month_selection.asp?queryDate=NULL"
>> Else
> > Set DBConn = Server.CreateObject ("ADODB.Connection")
> > DBConn.Open "Provider=SQLOLEDB; Data Source=OPERATIONS-01;" & _
> > "Initial Catalog=######;UId=######;pwd=######;"
> > ' GET ALL TIMES FOR PARTICULAR DAY
> > Set rstTimes = Server.CreateObject("ADODB.Recordset")
> > strSQL1 = ("SELECT * FROM DaysAndTimes WHERE " _
> > & "TODAY = '" & (Request.QueryString("queryDay")) & "'")
> > rstTimes.Open strSQL1, DBConn
> > ' COMPARE ALL TIMES TO SCHEDULED APPOINTMENT TIMES
> > Set rstTimeCheck = Server.CreateObject("ADODB.Recordset")
> > strSQL2 = ("SELECT IsOkay FROM AppDetails WHERE " _
> > & "AppTime = '" & (rstTimes("AvailableTime")) & "' AND " _
> > & "AppDate = '" & (Request.QueryString("queryDate")) &
>"'")
> > rstTimeCheck.Open strSQL2, DBConn
> > ' SHOW TIMES AS "UNAVAILABLE" IF TAKEN
> > If (rstTimeCheck("IsOkay")) = "UA" Then
> > TheMessage1 = "--TIME UNAVAILABLE--"
> > Else
> > TheMessage1 = " "
> > End If
>> End If
>> ***I'M WANTING MY TABLE TO SHOW AVAILABLE AND UNAVAILABLE TIMES BASED
>ON
>> rstTimeCheck("IsOkay")
>> ***HERE IS THE TABLE
>> <%
>> i=i
>> do until rstTimes.EOF
> > %>
> > <form method="post" id="form1" name="form1"><TR>
> > <% If (rstTimeCheck("IsOkay")) = "UA" Then %>
> > <TD width="75" align="middle" height="30"><%
>Response.Write rstTimes("AvailableTime")
> > %></TD>
> > <TD width="450" height="30"><% Response.Write
>TheMessage1%>
> > <!-- IF REQUESTED TIME IN UNAVAILABLE -->
> > <% Else %><TD width="75" align="middle" height="30"><%
>Response.Write rstTimes("AvailableTime")
> > %></TD>
> > <TD width="450" height="30"><INPUT id="Text1" type="text"
>name="Text1">
> > <IMG height="1" src="i/clear.gif" width="20">
> > <IMG height="1" src="i/clear.gif" width="15"> <INPUT
>id="Submit1" type="submit"
> > value="Submit" name="Submit1">
> > <IMG height="1" src="i/clear.gif" width="20">SELECT THIS
>TIME </TD>
> > <% End If %></TD>
> > </TR></form>
> > <%
> > rstTimes.MoveNext
>> loop
>> %>
>> ***RIGHT NOW THE WAY I HAVE THIS WRITTEN IT DOES NOT DIFFERENTIATE
>BASED
>> ON rstTimeCheck("IsOkay")
>>
>> "Kris Eiben" <eibenkthisisforspammers@yahoo.com> wrote:
>> >PLEASE keep it in the newsgroup. (The email address I use here is a
>> >spam trap.) What do you have?
>> >
>> >"Kyle" <kfinch@bayoucitygroup.com> wrote in message
>> >news:3ed39435$1@tnews.web.dev-archive.com...
>> >>
>> >> Thanks Kris
>> >> Can I tell you a little more about what I'm trying to do? I'm still
>> >getting
>> >> an error. I can tell it's trying to work, but not quite there. You
>can
>> >email
>> >> me directly if you like.
>> >>
>> >>
>> >> "Kris Eiben" <eibenkthisisforspammers@yahoo.com> wrote:
>> >> >Sure, it's possible. But it can be time-costly, and may not be
>> >> >necessary.
>> >> >
>> >> >If you're going to loop over the same records each time, you could
>> >> >create that second recordset outside the loop and put it into an
>> >array
>> >> >using GetRows(). Then you could just loop over the array inside
>the
>> >> >recordset loop. Depending on the size of the recordsets, this
>could
>> >> >give you a significant speed boost. More on GetRows here (this is
>> >> >obviously one of his pet peeves, but it's got good examples):
>> >> >http://www.learnasp.com/advice/whygetrows.asp
>> >> >
>> >> >If you need to get new data for each iteration through the outer
>> >loop,
>> >> >you might think about combining the data into 1 recordset, to
>speed
>> >> >things up. If that's not possible, the syntax you're looking for
>is:
>> >> >do until rstTimes.EOF
>> >> > nInnerLoopID = rstTimes("someID")
>> >> > sSQL = "Select somedata from sometable where id = " &
>> >nInnerLoopID
>> >> > set rsInnerLoop = Conn.Execute(sSQL)
>> >> > do until rsInnerLoop.EOF
>> >> > sSomeData = rsInnerLoop("somedata")
>> >> > dosomethingwith(sSomeData)
>> >> > rsInnerLoop.MoveNext
>> >> > loop
>> >> > rstTimes.MoveNext
>> >> >loop
>> >> >
>> >> >"kyle" <kfinch@bayoucitygroup.com> wrote in message
>> >> >news:3ed367cf$1@tnews.web.dev-archive.com...
>> >> >>
>> >> >> I'm trying to build a daily schedule that shows available and
>> >> >unavailable
>> >> >> times on a particular day based on a queryString upon entering
>the
>> >> >page.
>> >> >> Is it possible to have 2 looping functions on the same page?
>Right
>> >now
>> >> >I
>> >> >> have:
>> >> >> <%
>> >> >> i=i
>> >> >> Do Until rstTimes.EOF
>> >> >> %>
>> >> >> *** I NEED ANOTHER RECORDSET TO LOOP IN HERE ***
>> >> >> <%
>> >> >> i=i+1
>> >> >> rstTimes.Movenext
>> >> >> Loop
>> >> >> %>
>> >> >> If someone has any ideas or would like to see more of the page I
>> >can
>> >> >give
>> >> >> more details. Any help would be greatly appreciated. I'm a
>little
>> >> >behind
>> >> >> on this now.
>
>
Kyle at 2007-11-11 23:21:57 >

# 7 Re: looping
OK, it sounds like you need an outer join on the AppDetails table. That
will give you all the records in the DaysAndTimes table whether or not
it has matching AppDetails data. Sound like what you want?
You're using SQL Server? Well, I'm _extremely_ rusty with this syntax
(I use the Oracle (+) method for outer joins), but I'll give it a stab.
For readability I'll use <day> and <date> in the query -- in the actual
code you'll need to substitute request.querystring("queryDay") and
request.querystring("queryDate").
Note: this syntax is probably wrong -- missing parens or brackets or
something. Please check it with somebody who actually writes SQL Server
queries on a regular basis. **Any SQL Server users reading this thread,
check me please.**
Select dat.AvailableTime, ad.IsOkay
From DaysAndTimes dat Left Outer Join AppDetails ad
On dat.AvailableTime = ad.AppTime
Where dat.Today = <day>
And ad.AppDate = <date>
"Kyle" <kfinch@bayoucitygroup.com> wrote in message
news:3ed511ad$1@tnews.web.dev-archive.com...
>
> Almost perfect Kris. You're helping with my incredible headache.
> Now it only shows the times that are unavailable. I'm so close now,
but it
> has to show all the times. Man, you're going on the Christmas list for
helping
> me with this. The DaysAndTimes table shows times in thirty minute
increments
> from 9:00 to 6:00. I need all those to show
> ********** this is what i have now
>
> Dim DBConn, rstTimes, rstTimeCheck, strSQL, TheMessage1, i
>
> If isEmpty(Request.QueryString("queryDate")) Then
> Response.Redirect "./month_selection.asp?queryDate=NULL"
> Else
> Set DBConn = Server.CreateObject ("ADODB.Connection")
> DBConn.Open "Provider=SQLOLEDB; Data Source=OPERATIONS-01;" & _
> "Initial Catalog=SierraTherapy;UId=SA;pwd=2121118;"
> ' GET ALL TIMES FOR PARTICULAR DAY
> Set rstTimes = Server.CreateObject("ADODB.Recordset")
> strSQL = "Select dat.AvailableTime, ad.IsOkay" &_
> " from DaysAndTimes dat, AppDetails ad" &_
> " where dat.AvailableTime = ad.AppTime" &_
> " and dat.Today = '" & request.querystring("queryDay") & "'" &_
> " and ad.AppDate = '" & request.querystring("queryDate") & "'"
> rstTimes.Open strSQL, DBConn
> ' SHOW TIMES AS "UNAVAILABLE" IF TAKEN
> If (rstTimes("IsOkay")) = "UA" Then
> TheMessage1 = "--TIME UNAVAILABLE--"
> End If
> End If
>
>
> <%
> i=i
> do until rstTimes.EOF
> %>
> <form method="post" id="form1" name="form1"><TR>
> <!-- IF REQUESTED TIME IS UNAVAILABLE -->
> <% If Not isEmpty (rstTimes("IsOkay")) Then %>
> <TD width="75" align="middle" height="30"><% Response.Write
rstTimes("AvailableTime")
> %></TD>
> <TD width="450" height="30"><% Response.Write TheMessage1%>
> <% Else %><TD width="75" align="middle" height="30"><% Response.Write
rstTimes("AvailableTime")
> %></TD>
> <TD width="450" height="30"><INPUT id="Text1" type="text"
name="Text1">
> <IMG height="1" src="i/clear.gif" width="20">
> <IMG height="1" src="i/clear.gif" width="15"> <INPUT id="Submit1"
type="submit"
> value="Submit" name="Submit1">
> <IMG height="1" src="i/clear.gif" width="20">SELECT THIS TIME</TD>
> <% End If %></TD>
> </TR></form>
> <%
> rstTimes.MoveNext
> loop
> %>
>
> **********
>
> "Kris Eiben" <eibenkthisisforspammers@yahoo.com> wrote:
> >You're not looping over rstTimeCheck at all. Why not combine into
one
> >recordset?
> >
> >sSQL = "Select dat.AvailableTime, ad.IsOkay" &_
> > " from DaysAndTimes dat, AppDetails ad" &_
> > " where dat.AvailableTime = ad.AppTime" &_
> > " and dat.Today = '" &
request.querystring("queryDay") &
> >"'" &_
> > " and ad.AppDate = '" &
request.querystring("queryDate")
> >& "'"
> >
