470,580 Members | 2,327 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,580 developers. It's quick & easy.

Trying to display a message if there is nothing available

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!
Jul 19 '05 #1
4 2967
Are you sure that's where the error is occurring? If so:

Replace "elseif" with just a plain "else"

Ray at work

"J. Muenchbourg" <an*******@dex.com> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...
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!

Jul 19 '05 #2
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.
Jul 19 '05 #3
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" <an*******@dex.com> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...
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!

Jul 19 '05 #4
<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
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by apchar | last post: by
33 posts views Thread by selowitch | last post: by
7 posts views Thread by Stefan Finzel | last post: by
25 posts views Thread by Neo Geshel | last post: by
4 posts views Thread by Martin Schneider | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.