Trying to display a message if there is nothing available

J

J. Muenchbourg

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
 
R

Ray at

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

Replace "elseif" with just a plain "else"

Ray at work
 
B

Bob Barrows

J. Muenchbourg said:
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
 
T

TomB

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

dlbjr

<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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top