Trying to display a message if there is nothing available

Discussion in 'ASP General' started by J. Muenchbourg, Nov 25, 2003.

  1. I've created a page where users can view a free sports pick for the day;
    but if there is no free pick yet for that day, I want to display a
    "Check Back later today " message with the following:

    <%
    dim sqlstr
    sqlstr = "SELECT fpick FROM tblArticles where handid = '40' and
    ArticleDate = '" & date() & "'"

    Set rsor = Server.CreateObject("ADODB.Recordset")
    rsor.Open sqlstr,sqlc,3
    %>
    <h4><% if rsor("fpick") <> "" then
    response.write rsor("fpick")
    elseif rsor("fpick") = "" then
    response.write "Check back later today<br>"
    end if %>

    This produces an "Exception Occured" error if there is no free pick

    ???
    Muench

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    J. Muenchbourg, Nov 25, 2003
    #1
    1. Advertising

  2. J. Muenchbourg

    Ray at Guest

    Are you sure that's where the error is occurring? If so:

    Replace "elseif" with just a plain "else"

    Ray at work

    "J. Muenchbourg" <> wrote in message
    news:...
    > I've created a page where users can view a free sports pick for the day;
    > but if there is no free pick yet for that day, I want to display a
    > "Check Back later today " message with the following:
    >
    > <%
    > dim sqlstr
    > sqlstr = "SELECT fpick FROM tblArticles where handid = '40' and
    > ArticleDate = '" & date() & "'"
    >
    > Set rsor = Server.CreateObject("ADODB.Recordset")
    > rsor.Open sqlstr,sqlc,3
    > %>
    > <h4><% if rsor("fpick") <> "" then
    > response.write rsor("fpick")
    > elseif rsor("fpick") = "" then
    > response.write "Check back later today<br>"
    > end if %>
    >
    > This produces an "Exception Occured" error if there is no free pick
    >
    > ???
    > Muench
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Ray at, Nov 25, 2003
    #2
    1. Advertising

  3. J. Muenchbourg

    Bob Barrows Guest

    J. Muenchbourg wrote:
    > I've created a page where users can view a free sports pick for the
    > day; but if there is no free pick yet for that day, I want to display
    > a "Check Back later today " message with the following:
    >
    > <%
    > dim sqlstr
    > sqlstr = "SELECT fpick FROM tblArticles where handid = '40' and
    > ArticleDate = '" & date() & "'"
    >
    > Set rsor = Server.CreateObject("ADODB.Recordset")
    > rsor.Open sqlstr,sqlc,3
    > %>
    > <h4> <% if rsor("fpick") <> "" then
    > response.write rsor("fpick")
    > elseif rsor("fpick") = "" then
    > response.write "Check back later today<br>"
    > end if %>
    >
    > This produces an "Exception Occured" error if there is no free pick
    >

    Use EOF to determine if the recordset is empty:

    <% if NOT rsor.EOF then
    response.write rsor("fpick")
    else
    response.write "Check back later today<br>"
    end if %>

    HTH,
    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows, Nov 25, 2003
    #3
  4. J. Muenchbourg

    TomB Guest

    Set rsor = sqlc.Execute(sqlstr)
    Response.write "<h4>"
    if rsor.EOF then
    Response.write "Check back later today"
    else
    Response.write rsor.Fields("fpick")
    end if
    Response.write "</h4>"


    "J. Muenchbourg" <> wrote in message
    news:...
    > I've created a page where users can view a free sports pick for the day;
    > but if there is no free pick yet for that day, I want to display a
    > "Check Back later today " message with the following:
    >
    > <%
    > dim sqlstr
    > sqlstr = "SELECT fpick FROM tblArticles where handid = '40' and
    > ArticleDate = '" & date() & "'"
    >
    > Set rsor = Server.CreateObject("ADODB.Recordset")
    > rsor.Open sqlstr,sqlc,3
    > %>
    > <h4><% if rsor("fpick") <> "" then
    > response.write rsor("fpick")
    > elseif rsor("fpick") = "" then
    > response.write "Check back later today<br>"
    > end if %>
    >
    > This produces an "Exception Occured" error if there is no free pick
    >
    > ???
    > Muench
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    TomB, Nov 25, 2003
    #4
  5. J. Muenchbourg

    dlbjr Guest

    <SCRIPT language="vbscript" runat="server">
    Function GetPickOfTheDay()
    GetPickOfTheDay = "Check back later today"
    Set Conn = CreateObject("ADODB.Connection")
    Conn.ConnectionString = "What ever"
    sqlstr = "SELECT fpick FROM tblArticles WHERE handid='40' AND
    ArticleDate='"& Date() & "'"
    Set rs = CreateObject("ADODB.Recordset")
    rs.Open sqlstr,sqlc,3
    If Not rs.EOF Then
    GetPickOfTheDay = rs("fpick")
    End IF
    rs.Close
    Set rs = Nothing
    Set Conn = Nothing
    End Function
    </SCRIPT>
    <h4><%=GetPickOfTheDay()%><br/></h4>


    -dlbjr

    Discerning resolutions for the alms
     
    dlbjr, Nov 25, 2003
    #5
    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. David Cho
    Replies:
    2
    Views:
    423
    Patrice
    Mar 11, 2005
  2. Ed Burns
    Replies:
    3
    Views:
    190
    Aaron [SQL Server MVP]
    Aug 5, 2004
  3. Ben Thomas
    Replies:
    8
    Views:
    115
    Hal Fulton
    Nov 11, 2006
  4. Devin Jeanpierre
    Replies:
    2
    Views:
    473
    Devin Jeanpierre
    Feb 14, 2012
  5. Karen Wieprecht

    trying to "use Sys::Syslog" but I get nothing ...

    Karen Wieprecht, Jan 24, 2005, in forum: Perl Misc
    Replies:
    11
    Views:
    174
    Karen Wieprecht
    Jan 26, 2005
Loading...

Share This Page