Home > Archive > MS Access and Internet > April 2005 > Error message when the recordset is empty









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Error message when the recordset is empty
dsmith76

2005-04-06, 8:05 pm

I have a report page that accesses an access database on the internet. If
their are no results available in the access query, I want to put a message
that says "No results have been reported yet" or something to that effect.

I have made an SQL statement and I have tried code such as
If recordset("Fieldname") is null Then
Response.write "No results have been reported yet"
End If
but because no recordset was actually created, I just get an error message.
Any ideas? Thanks, Dave
Ken Snell [MVP]

2005-04-06, 8:05 pm

Post the code that you're using. Depending upon how you're creating the
recordset, likely you can test for BOF and EOF condition both being present
(which means the recordset has no records).

--

Ken Snell
<MS ACCESS MVP>

"dsmith76" < dsmith76@discussions
.microsoft.com> wrote in message
news:6E162C1D-422D-47B0-B23C- 4562B91D7661@microso
ft.com...
>I have a report page that accesses an access database on the internet. If
> their are no results available in the access query, I want to put a
> message
> that says "No results have been reported yet" or something to that effect.
>
> I have made an SQL statement and I have tried code such as
> If recordset("Fieldname") is null Then
> Response.write "No results have been reported yet"
> End If
> but because no recordset was actually created, I just get an error
> message.
> Any ideas? Thanks, Dave



dsmith76

2005-04-06, 8:05 pm

Ken,
Here is the code I am using now. If I am at the end of the file, I am just
saying response.end, which works fine but I am concerned that the recordset
is still open as well as the connection.

<!--Next is tie breaking code-->
<%
Set oRS=Server.Createobject("ADODB.recordset")
SQL= "SELECT * From Events,maillist,scor
es WHERE "
SQL=SQL & "Events.EventID=Scores.EventID and "
SQL=SQL & "maillist.mailid=Scores.mailid "
SQL=SQL & "and Events.EventID= " & eventid
SQL=SQL & " order by place"
ORS.open SQL, OC, adOpenStatic, adLockOptimistic, adCmdText
%>
<% Place=1
Count=0
%>
<% Do while not ors.eof
Share=0
Share=Share + ors("wilwinpt")
ors.movenext
If ors.eof THEN
response.write "That's the end of the file"
response.end
End if
%>

<!--This code splits up wilwin points in the case of ties-->
<%
If Ors("Place") = Place THEN
Count=1
Do Until ors("place") > place
Share=Share + ors("wilwinpt")
Count= Count+1
Wilwinpt=Share/Count
ors.movenext
if ors.eof THEN
Countb=Count
Do until Countb=0
ors.MovePrevious
oRS("wilwinpt")=wilwinpt
Countb=Countb-1
loop
ors.update
response.write "That's the end of the file"
response.end

Countc=0
Do until Countc=Count
ors.movenext
Countc=Countc + 1
loop
Place=0

End if
loop
%>


"Ken Snell [MVP]" wrote:

> Post the code that you're using. Depending upon how you're creating the
> recordset, likely you can test for BOF and EOF condition both being present
> (which means the recordset has no records).
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
>
> "dsmith76" < dsmith76@discussions
.microsoft.com> wrote in message
> news:6E162C1D-422D-47B0-B23C- 4562B91D7661@microso
ft.com...
>
>
>

Ken Snell [MVP]

2005-04-06, 8:05 pm

I admit that I do not know the syntax of the exact language that you're
using here (VBScript?), but I believe that you can insert an If .. Then test
before you try looping through the recordset's records -- see the line that
begins with

<% If ors.eof = True And ors.bof = True Then


-----------

<!--Next is tie breaking code-->
<%
Set oRS=Server.Createobject("ADODB.recordset")
SQL= "SELECT * From Events,maillist,scor
es WHERE "
SQL=SQL & "Events.EventID=Scores.EventID and "
SQL=SQL & "maillist.mailid=Scores.mailid "
SQL=SQL & "and Events.EventID= " & eventid
SQL=SQL & " order by place"
ORS.open SQL, OC, adOpenStatic, adLockOptimistic, adCmdText
%>
<% Place=1
Count=0
%>
<% If ors.eof = True And ors.bof = True Then
response.write "No records"
response.end
Else
Do while not ors.eof
Share=0
Share=Share + ors("wilwinpt")
ors.movenext
If ors.eof THEN
response.write "That's the end of the file"
response.end
End if
End If
%>

<!--This code splits up wilwin points in the case of ties-->
<%
If Ors("Place") = Place THEN
Count=1
Do Until ors("place") > place
Share=Share + ors("wilwinpt")
Count= Count+1
Wilwinpt=Share/Count
ors.movenext
if ors.eof THEN
Countb=Count
Do until Countb=0
ors.MovePrevious
oRS("wilwinpt")=wilwinpt
Countb=Countb-1
loop
ors.update
response.write "That's the end of the file"
response.end

Countc=0
Do until Countc=Count
ors.movenext
Countc=Countc + 1
loop
Place=0

End if
loop
%>

--

Ken Snell
<MS ACCESS MVP>


"dsmith76" < dsmith76@discussions
.microsoft.com> wrote in message
news:06D05276-0A47-41F8-8814- 3E4557118AB7@microso
ft.com...[color=darkred]
> Ken,
> Here is the code I am using now. If I am at the end of the file, I am just
> saying response.end, which works fine but I am concerned that the
> recordset
> is still open as well as the connection.
>
> <!--Next is tie breaking code-->
> <%
> Set oRS=Server.Createobject("ADODB.recordset")
> SQL= "SELECT * From Events,maillist,scor
es WHERE "
> SQL=SQL & "Events.EventID=Scores.EventID and "
> SQL=SQL & "maillist.mailid=Scores.mailid "
> SQL=SQL & "and Events.EventID= " & eventid
> SQL=SQL & " order by place"
> ORS.open SQL, OC, adOpenStatic, adLockOptimistic, adCmdText
> %>
> <% Place=1
> Count=0
> %>
> <% Do while not ors.eof
> Share=0
> Share=Share + ors("wilwinpt")
> ors.movenext
> If ors.eof THEN
> response.write "That's the end of the file"
> response.end
> End if
> %>
>
> <!--This code splits up wilwin points in the case of ties-->
> <%
> If Ors("Place") = Place THEN
> Count=1
> Do Until ors("place") > place
> Share=Share + ors("wilwinpt")
> Count= Count+1
> Wilwinpt=Share/Count
> ors.movenext
> if ors.eof THEN
> Countb=Count
> Do until Countb=0
> ors.MovePrevious
> oRS("wilwinpt")=wilwinpt
> Countb=Countb-1
> loop
> ors.update
> response.write "That's the end of the file"
> response.end
>
> Countc=0
> Do until Countc=Count
> ors.movenext
> Countc=Countc + 1
> loop
> Place=0
>
> End if
> loop
> %>
>
>
> "Ken Snell [MVP]" wrote:
>


dsmith76

2005-04-06, 8:05 pm

Thanks Ken, I'll give that a try.

Dave

"Ken Snell [MVP]" wrote:

> I admit that I do not know the syntax of the exact language that you're
> using here (VBScript?), but I believe that you can insert an If .. Then test
> before you try looping through the recordset's records -- see the line that
> begins with
>
> <% If ors.eof = True And ors.bof = True Then
>
>
> -----------
>
> <!--Next is tie breaking code-->
> <%
> Set oRS=Server.Createobject("ADODB.recordset")
> SQL= "SELECT * From Events,maillist,scor
es WHERE "
> SQL=SQL & "Events.EventID=Scores.EventID and "
> SQL=SQL & "maillist.mailid=Scores.mailid "
> SQL=SQL & "and Events.EventID= " & eventid
> SQL=SQL & " order by place"
> ORS.open SQL, OC, adOpenStatic, adLockOptimistic, adCmdText
> %>
> <% Place=1
> Count=0
> %>
> <% If ors.eof = True And ors.bof = True Then
> response.write "No records"
> response.end
> Else
> Do while not ors.eof
> Share=0
> Share=Share + ors("wilwinpt")
> ors.movenext
> If ors.eof THEN
> response.write "That's the end of the file"
> response.end
> End if
> End If
> %>
>
> <!--This code splits up wilwin points in the case of ties-->
> <%
> If Ors("Place") = Place THEN
> Count=1
> Do Until ors("place") > place
> Share=Share + ors("wilwinpt")
> Count= Count+1
> Wilwinpt=Share/Count
> ors.movenext
> if ors.eof THEN
> Countb=Count
> Do until Countb=0
> ors.MovePrevious
> oRS("wilwinpt")=wilwinpt
> Countb=Countb-1
> loop
> ors.update
> response.write "That's the end of the file"
> response.end
>
> Countc=0
> Do until Countc=Count
> ors.movenext
> Countc=Countc + 1
> loop
> Place=0
>
> End if
> loop
> %>
>
> --
>
> Ken Snell
> <MS ACCESS MVP>
>
>
> "dsmith76" < dsmith76@discussions
.microsoft.com> wrote in message
> news:06D05276-0A47-41F8-8814- 3E4557118AB7@microso
ft.com...
>
>
>

Cecilia Lo Gatto

2005-04-21, 8:25 pm

In 06D05276-0A47-41F8-8814- 3E4557118AB7@microso
ft.com, dsmith76,
dsmith76@discussions
.microsoft.com, il 13-03-2005 22:51 ha scritto:
[color=darkred]
> Ken,
> Here is the code I am using now. If I am at the end of the file, I am just
> saying response.end, which works fine but I am concerned that the recordset
> is still open as well as the connection.
>
> <!--Next is tie breaking code-->
> <%
> Set oRS=Server.Createobject("ADODB.recordset")
> SQL= "SELECT * From Events,maillist,scor
es WHERE "
> SQL=SQL & "Events.EventID=Scores.EventID and "
> SQL=SQL & "maillist.mailid=Scores.mailid "
> SQL=SQL & "and Events.EventID= " & eventid
> SQL=SQL & " order by place"
> ORS.open SQL, OC, adOpenStatic, adLockOptimistic, adCmdText
> %>
> <% Place=1
> Count=0
> %>
> <% Do while not ors.eof
> Share=0
> Share=Share + ors("wilwinpt")
> ors.movenext
> If ors.eof THEN
> response.write "That's the end of the file"
> response.end
> End if
> %>
>
> <!--This code splits up wilwin points in the case of ties-->
> <%
> If Ors("Place") = Place THEN
> Count=1
> Do Until ors("place") > place
> Share=Share + ors("wilwinpt")
> Count= Count+1
> Wilwinpt=Share/Count
> ors.movenext
> if ors.eof THEN
> Countb=Count
> Do until Countb=0
> ors.MovePrevious
> oRS("wilwinpt")=wilwinpt
> Countb=Countb-1
> loop
> ors.update
> response.write "That's the end of the file"
> response.end
>
> Countc=0
> Do until Countc=Count
> ors.movenext
> Countc=Countc + 1
> loop
> Place=0
>
> End if
> loop
> %>
>
>
> "Ken Snell [MVP]" wrote:
>
ma nessuno di voi parla italiano?
but nobudy speak italian?

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com