Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > IF Statement

Reply
Thread Tools

IF Statement

 
 
Keith
Guest
Posts: n/a
 
      06-24-2004
How can I do the following:

If recordset is empty, redirect to page1 but if recordset has something in,
redirect to page 2.

Thanks


 
Reply With Quote
 
 
 
 
Steven Burn
Guest
Posts: n/a
 
      06-24-2004
valTemp = rst.RecordCount
Select Case valTemp
Case 0
Response.Redirect "nothing_in_there.asp"
Case Else
Response.Redirect "something_in_there.asp"
End Select

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!


"Keith" <@.> wrote in message news:#(E-Mail Removed)...
> How can I do the following:
>
> If recordset is empty, redirect to page1 but if recordset has something

in,
> redirect to page 2.
>
> Thanks
>
>



 
Reply With Quote
 
 
 
 
Aaron [SQL Server MVP]
Guest
Posts: n/a
 
      06-24-2004
set rs = conn.execute(sql)
if rs.eof then
response.redirect("page1.asp")
else
response.redirect("page2.asp")
end if


--
http://www.aspfaq.com/
(Reverse address to reply.)




"Keith" <@.> wrote in message news:#(E-Mail Removed)...
> How can I do the following:
>
> If recordset is empty, redirect to page1 but if recordset has something

in,
> redirect to page 2.
>
> Thanks
>
>



 
Reply With Quote
 
Aaron [SQL Server MVP]
Guest
Posts: n/a
 
      06-24-2004
> valTemp = rst.RecordCount
> Select Case valTemp
> Case 0
> Response.Redirect "nothing_in_there.asp"
> Case Else
> Response.Redirect "something_in_there.asp"
> End Select


Except, RecordCount isn't available with the default cursor (-1 is the
default), so your Else will probably always fire.

The EOF property will tell you if the resultset is empty without having to
rely on a count.

A


 
Reply With Quote
 
Steven Burn
Guest
Posts: n/a
 
      06-24-2004
I actually generally use;

If rst.RecordCount > 0 then
'// Something
End If

Just figured I'd be creative \

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!


"Aaron [SQL Server MVP]" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> > valTemp = rst.RecordCount
> > Select Case valTemp
> > Case 0
> > Response.Redirect "nothing_in_there.asp"
> > Case Else
> > Response.Redirect "something_in_there.asp"
> > End Select

>
> Except, RecordCount isn't available with the default cursor (-1 is the
> default), so your Else will probably always fire.
>
> The EOF property will tell you if the resultset is empty without having to
> rely on a count.
>
> A
>
>



 
Reply With Quote
 
Keith
Guest
Posts: n/a
 
      06-24-2004
How (if possible) could I modify this so that it redirects to page 1 if RS
was NOT eof OR if a sessionvariable1 contained value1

If the session variable containes any other value or if the rs IS eof then
redirect to page 2

Thanks


"Aaron [SQL Server MVP]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> set rs = conn.execute(sql)
> if rs.eof then
> response.redirect("page1.asp")
> else
> response.redirect("page2.asp")
> end if
>
>
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
>
>
> "Keith" <@.> wrote in message news:#(E-Mail Removed)...
> > How can I do the following:
> >
> > If recordset is empty, redirect to page1 but if recordset has something

> in,
> > redirect to page 2.
> >
> > Thanks
> >
> >

>
>



 
Reply With Quote
 
Steven Burn
Guest
Posts: n/a
 
      06-24-2004
set rs = conn.execute(sql)
if not rs.eof or sessionvarible1 = "1" then
response.redirect("page1.asp")
else
response.redirect("page2.asp")
end if

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!


"Keith" <@.> wrote in message news:u$(E-Mail Removed)...
> How (if possible) could I modify this so that it redirects to page 1 if RS
> was NOT eof OR if a sessionvariable1 contained value1
>
> If the session variable containes any other value or if the rs IS eof then
> redirect to page 2
>
> Thanks
>
>
> "Aaron [SQL Server MVP]" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > set rs = conn.execute(sql)
> > if rs.eof then
> > response.redirect("page1.asp")
> > else
> > response.redirect("page2.asp")
> > end if
> >
> >
> > --
> > http://www.aspfaq.com/
> > (Reverse address to reply.)
> >
> >
> >
> >
> > "Keith" <@.> wrote in message

news:#(E-Mail Removed)...
> > > How can I do the following:
> > >
> > > If recordset is empty, redirect to page1 but if recordset has

something
> > in,
> > > redirect to page 2.
> > >
> > > Thanks
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Dave Anderson
Guest
Posts: n/a
 
      06-24-2004
Keith wrote:
> How can I do the following:
>
> If recordset is empty, redirect to page1 but if recordset has
> something in, redirect to page 2.


if (RS.EOF) {
<<< do stuff, close connection, etc. >>>
Response.Redirect("p1.asp")
}

<<< do other stuff, close RS & CN >>>
Response.Redirect("p2.asp")



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.


 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      06-24-2004
Again, this use of RecordCount requires the use of an expensive cursor type.
Use the EOF property instead (as Aaron correctly suggested):

'//immediately after opening the recordset:
If not rst.EOF then
'//recordset is not empty
else
'//recordset is empty
end if

Bob Barrows

Steven Burn wrote:
> I actually generally use;
>
> If rst.RecordCount > 0 then
> '// Something
> End If
>
> Just figured I'd be creative \
>
>
> "Aaron [SQL Server MVP]" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
>>> valTemp = rst.RecordCount
>>> Select Case valTemp
>>> Case 0
>>> Response.Redirect "nothing_in_there.asp"
>>> Case Else
>>> Response.Redirect "something_in_there.asp"
>>> End Select

>>
>> Except, RecordCount isn't available with the default cursor (-1 is
>> the default), so your Else will probably always fire.
>>
>> The EOF property will tell you if the resultset is empty without
>> having to rely on a count.
>>
>> A


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
Steven Burn
Guest
Posts: n/a
 
      06-24-2004
Been taking a look into it since Aaron mentioned it ;o) (so far, I can't see
the difference as far as performance is concerned?)

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!


"Bob Barrows [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Again, this use of RecordCount requires the use of an expensive cursor

type.
> Use the EOF property instead (as Aaron correctly suggested):
>
> '//immediately after opening the recordset:
> If not rst.EOF then
> '//recordset is not empty
> else
> '//recordset is empty
> end if
>
> Bob Barrows
>
> Steven Burn wrote:
> > I actually generally use;
> >
> > If rst.RecordCount > 0 then
> > '// Something
> > End If
> >
> > Just figured I'd be creative \
> >
> >
> > "Aaron [SQL Server MVP]" <(E-Mail Removed)> wrote in message
> > news:#(E-Mail Removed)...
> >>> valTemp = rst.RecordCount
> >>> Select Case valTemp
> >>> Case 0
> >>> Response.Redirect "nothing_in_there.asp"
> >>> Case Else
> >>> Response.Redirect "something_in_there.asp"
> >>> End Select
> >>
> >> Except, RecordCount isn't available with the default cursor (-1 is
> >> the default), so your Else will probably always fire.
> >>
> >> The EOF property will tell you if the resultset is empty without
> >> having to rely on a count.
> >>
> >> A

>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if statement that, when false, skips first statement in its block, executes second? Jay McGavren Java 11 01-16-2006 05:49 PM
How do I do a conditional statement in a constant statement? tkvhdl@gmail.com VHDL 3 12-16-2005 06:13 PM
Which of switch statement and if-else statement takes less time to execute? swaroophr@gmail.com C Programming 21 08-02-2005 09:24 AM
exec "statement" VS. exec "statement in globals(), locals() Ted Python 1 07-22-2004 08:51 AM
exec "statement" VS. exec "statement" in globals(), locals() tedsuzman Python 2 07-21-2004 08:41 PM



Advertisments