IF Statement

Discussion in 'ASP General' started by Keith, Jun 24, 2004.

  1. Keith

    Keith Guest

    How can I do the following:

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

    Thanks
     
    Keith, Jun 24, 2004
    #1
    1. Advertising

  2. Keith

    Steven Burn Guest

    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:#...
    > How can I do the following:
    >
    > If recordset is empty, redirect to page1 but if recordset has something

    in,
    > redirect to page 2.
    >
    > Thanks
    >
    >
     
    Steven Burn, Jun 24, 2004
    #2
    1. Advertising

  3. 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:#...
    > How can I do the following:
    >
    > If recordset is empty, redirect to page1 but if recordset has something

    in,
    > redirect to page 2.
    >
    > Thanks
    >
    >
     
    Aaron [SQL Server MVP], Jun 24, 2004
    #3
  4. > 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
     
    Aaron [SQL Server MVP], Jun 24, 2004
    #4
  5. Keith

    Steven Burn Guest

    I actually generally use;

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

    Just figured I'd be creative :eek:\

    --

    Regards

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

    Keeping it FREE!


    "Aaron [SQL Server MVP]" <> wrote in message
    news:#...
    > > 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
    >
    >
     
    Steven Burn, Jun 24, 2004
    #5
  6. Keith

    Keith Guest

    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]" <> wrote in message
    news:%...
    > 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:#...
    > > How can I do the following:
    > >
    > > If recordset is empty, redirect to page1 but if recordset has something

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

    >
    >
     
    Keith, Jun 24, 2004
    #6
  7. Keith

    Steven Burn Guest

    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$...
    > 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]" <> wrote in message
    > news:%...
    > > 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:#...
    > > > How can I do the following:
    > > >
    > > > If recordset is empty, redirect to page1 but if recordset has

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

    > >
    > >

    >
    >
     
    Steven Burn, Jun 24, 2004
    #7
  8. 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.
     
    Dave Anderson, Jun 24, 2004
    #8
  9. 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 :eek:\
    >
    >
    > "Aaron [SQL Server MVP]" <> wrote in message
    > news:#...
    >>> 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"
     
    Bob Barrows [MVP], Jun 24, 2004
    #9
  10. Keith

    Steven Burn Guest

    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]" <> wrote in message
    news:...
    > 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 :eek:\
    > >
    > >
    > > "Aaron [SQL Server MVP]" <> wrote in message
    > > news:#...
    > >>> 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"
    >
    >
     
    Steven Burn, Jun 24, 2004
    #10
  11. > 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?)


    The performance comes in when you switch to using an expensive, non-default
    recordset just to get the recordcount property.

    http://www.aspfaq.com/2191

    He wasn't making a decision based on a specific recordcount, just an empty /
    non-empty set. So why go to all that trouble when you already have an EOF
    property to check?

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)
     
    Aaron [SQL Server MVP], Jun 24, 2004
    #11
  12. Keith

    Keith Guest

    Thanks everyone for your help

    "Keith" <@.> wrote in message news:%...
    > How can I do the following:
    >
    > If recordset is empty, redirect to page1 but if recordset has something

    in,
    > redirect to page 2.
    >
    > Thanks
    >
    >
     
    Keith, Jun 24, 2004
    #12
  13. On its own, you might not. Did you switch to using the less expensive cursor
    type and location: adOpenForwardOnly and adUseServer? Even if you did, you
    probably did not notice the decrease in memory resources and cpu cycles used
    on both the web and database servers when opening the less expensive cursor
    type. But I guarantee you that the servers did "notice" it, and if you make
    the change in enough pages that were using the more expensive cursor types,
    you may notice an increase in overall performance of your server.

    Of course, if your web server does not get a lot of usage, you still might
    not notice it, but that does not mean that this is not a Best Practice which
    you should get into the habit of using:

    Use the cheapest cursor type required to support your application's
    functionality. For the most part in ASP, you will not need to use a
    bookmarkable cursor (i.e., a cursor which supports scrolling and
    recordcount), so you should use the default cursor in almost all cases. If
    you DO need extra functionality (filter, etc.), then make sure you
    disconnect the recordset while processing it.

    Bob Barrows

    Steven Burn wrote:
    > 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?)
    >
    >
    > "Bob Barrows [MVP]" <> wrote in message
    > news:...
    >> 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 :eek:\
    >>>
    >>>
    >>> "Aaron [SQL Server MVP]" <> wrote in message
    >>> news:#...
    >>>>> 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"


    --
    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"
     
    Bob Barrows [MVP], Jun 24, 2004
    #13
  14. Keith

    Steven Burn Guest

    ooo, nice info... cheers Aaron :eek:) (suddenly I feel like an edgit, lol)

    --

    Regards

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

    Keeping it FREE!


    "Aaron [SQL Server MVP]" <> wrote in message
    news:...
    > > 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?)

    >
    > The performance comes in when you switch to using an expensive,

    non-default
    > recordset just to get the recordcount property.
    >
    > http://www.aspfaq.com/2191
    >
    > He wasn't making a decision based on a specific recordcount, just an empty

    /
    > non-empty set. So why go to all that trouble when you already have an EOF
    > property to check?
    >
    > --
    > http://www.aspfaq.com/
    > (Reverse address to reply.)
    >
    >
     
    Steven Burn, Jun 24, 2004
    #14
  15. Keith

    Steven Burn Guest

    Bob,
    To be honest, I didn't know about the two ad's you mentioned :eek:\

    Thanks for the info :eek:)

    --

    Regards

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

    Keeping it FREE!


    "Bob Barrows [MVP]" <> wrote in message
    news:...
    > On its own, you might not. Did you switch to using the less expensive

    cursor
    > type and location: adOpenForwardOnly and adUseServer? Even if you did, you
    > probably did not notice the decrease in memory resources and cpu cycles

    used
    > on both the web and database servers when opening the less expensive

    cursor
    > type. But I guarantee you that the servers did "notice" it, and if you

    make
    > the change in enough pages that were using the more expensive cursor

    types,
    > you may notice an increase in overall performance of your server.
    >
    > Of course, if your web server does not get a lot of usage, you still might
    > not notice it, but that does not mean that this is not a Best Practice

    which
    > you should get into the habit of using:
    >
    > Use the cheapest cursor type required to support your application's
    > functionality. For the most part in ASP, you will not need to use a
    > bookmarkable cursor (i.e., a cursor which supports scrolling and
    > recordcount), so you should use the default cursor in almost all cases. If
    > you DO need extra functionality (filter, etc.), then make sure you
    > disconnect the recordset while processing it.
    >
    > Bob Barrows
    >
    > Steven Burn wrote:
    > > 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?)
    > >
    > >
    > > "Bob Barrows [MVP]" <> wrote in message
    > > news:...
    > >> 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 :eek:\
    > >>>
    > >>>
    > >>> "Aaron [SQL Server MVP]" <> wrote in message
    > >>> news:#...
    > >>>>> 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"

    >
    > --
    > 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"
    >
    >
     
    Steven Burn, Jun 24, 2004
    #15
  16. Keith

    Mark Schupp Guest

    I would strongly suggest closing the recordset and connection before the
    redirect. This should take place automatically when the page goes out of
    score but I am a strong believer in "if you open it, close it" and "if you
    create it, destroy it" (never have liked automatic garbage collectors).

    set rs = conn.execute(sql)
    if not rs.eof or sessionvarible1 = "1" then
    targeturl = "page1.asp"
    else
    targeturl = "page2.asp"
    end if

    rs.close
    set rs=nothing
    conn.close
    set conn=nothing

    response.redirect targeturl

    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    www.ielearning.com


    "Steven Burn" <> wrote in message
    news:%23$...
    > 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$...
    > > 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]" <> wrote in message
    > > news:%...
    > > > 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:#...
    > > > > How can I do the following:
    > > > >
    > > > > If recordset is empty, redirect to page1 but if recordset has

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

    > >
    > >

    >
    >
     
    Mark Schupp, Jun 24, 2004
    #16
  17. Go here:
    http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoenumerations.asp

    From which you can link to :
    http://msdn.microsoft.com/library/en-us/ado270/htm/mdcstcursorlocationenum.asp

    and
    http://msdn.microsoft.com/library/en-us/ado270/htm/mdcstcursortypeenum.asp

    Bob Barrows

    Steven Burn wrote:
    > Bob,
    > To be honest, I didn't know about the two ad's you mentioned :eek:\
    >
    > Thanks for the info :eek:)
    >
    >
    > "Bob Barrows [MVP]" <> wrote in message
    > news:...
    >> On its own, you might not. Did you switch to using the less
    >> expensive cursor type and location: adOpenForwardOnly and
    >> adUseServer? Even if you did, you probably did not notice the
    >> decrease in memory resources and cpu cycles used on both the web and
    >> database servers when opening the less expensive cursor type. But I
    >> guarantee you that the servers did "notice" it, and if you make the
    >> change in enough pages that were using the more expensive cursor
    >> types, you may notice an increase in overall performance of your
    >> server.
    >>
    >> Of course, if your web server does not get a lot of usage, you still
    >> might not notice it, but that does not mean that this is not a Best
    >> Practice which you should get into the habit of using:
    >>
    >> Use the cheapest cursor type required to support your application's
    >> functionality. For the most part in ASP, you will not need to use a
    >> bookmarkable cursor (i.e., a cursor which supports scrolling and
    >> recordcount), so you should use the default cursor in almost all
    >> cases. If you DO need extra functionality (filter, etc.), then make
    >> sure you disconnect the recordset while processing it.
    >>
    >> Bob Barrows
    >>
    >> Steven Burn wrote:
    >>> 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?)
    >>>
    >>>
    >>> "Bob Barrows [MVP]" <> wrote in message
    >>> news:...
    >>>> 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 :eek:\
    >>>>>
    >>>>>
    >>>>> "Aaron [SQL Server MVP]" <> wrote in message
    >>>>> news:#...
    >>>>>>> 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"

    >>
    >> --
    >> 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"


    --
    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"
     
    Bob Barrows [MVP], Jun 24, 2004
    #17
  18. Keith

    Steven Burn Guest

    ooo nice one, thankyou :eek:)

    --

    Regards

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

    Keeping it FREE!


    "Bob Barrows [MVP]" <> wrote in message
    news:#...
    > Go here:
    >

    http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoenumerations.asp
    >
    > From which you can link to :
    >

    http://msdn.microsoft.com/library/en-us/ado270/htm/mdcstcursorlocationenum.a
    sp
    >
    > and
    > http://msdn.microsoft.com/library/en-us/ado270/htm/mdcstcursortypeenum.asp
    >
    > Bob Barrows
    >
    > Steven Burn wrote:
    > > Bob,
    > > To be honest, I didn't know about the two ad's you mentioned :eek:\
    > >
    > > Thanks for the info :eek:)
    > >
    > >
    > > "Bob Barrows [MVP]" <> wrote in message
    > > news:...
    > >> On its own, you might not. Did you switch to using the less
    > >> expensive cursor type and location: adOpenForwardOnly and
    > >> adUseServer? Even if you did, you probably did not notice the
    > >> decrease in memory resources and cpu cycles used on both the web and
    > >> database servers when opening the less expensive cursor type. But I
    > >> guarantee you that the servers did "notice" it, and if you make the
    > >> change in enough pages that were using the more expensive cursor
    > >> types, you may notice an increase in overall performance of your
    > >> server.
    > >>
    > >> Of course, if your web server does not get a lot of usage, you still
    > >> might not notice it, but that does not mean that this is not a Best
    > >> Practice which you should get into the habit of using:
    > >>
    > >> Use the cheapest cursor type required to support your application's
    > >> functionality. For the most part in ASP, you will not need to use a
    > >> bookmarkable cursor (i.e., a cursor which supports scrolling and
    > >> recordcount), so you should use the default cursor in almost all
    > >> cases. If you DO need extra functionality (filter, etc.), then make
    > >> sure you disconnect the recordset while processing it.
    > >>
    > >> Bob Barrows
    > >>
    > >> Steven Burn wrote:
    > >>> 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?)
    > >>>
    > >>>
    > >>> "Bob Barrows [MVP]" <> wrote in message
    > >>> news:...
    > >>>> 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 :eek:\
    > >>>>>
    > >>>>>
    > >>>>> "Aaron [SQL Server MVP]" <> wrote in message
    > >>>>> news:#...
    > >>>>>>> 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"
    > >>
    > >> --
    > >> 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"

    >
    > --
    > 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"
    >
    >
     
    Steven Burn, Jun 24, 2004
    #18
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    807
  2. Jay McGavren
    Replies:
    11
    Views:
    1,140
    Alan Krueger
    Jan 16, 2006
  3. tedsuzman
    Replies:
    2
    Views:
    7,094
    Michel Claveau, résurectionné d'outre-bombe inform
    Jul 21, 2004
  4. Ted
    Replies:
    1
    Views:
    470
    Duncan Booth
    Jul 22, 2004
  5. Replies:
    21
    Views:
    1,060
    Giannis Papadopoulos
    Aug 2, 2005
Loading...

Share This Page