qry returns nothing (no data matched qry)

  • Thread starter Bob Green via .NET 247
  • Start date
B

Bob Green via .NET 247

I want to know how to determine if a qry through ASP to a access database returns nothing (ie. there is no record that matches the query). I want to write a message stating no matches found if no records match the search.

Here's the portion of code:

<%
dim strArtType
Set objRS = Server.CreateObject("ADODB.recordset")
objRS.open strSQL, strConnect

**!!?? Is there a boolean result for something like this??!!**
if objRS("Title") = empty then
response.write "The value of title is: "& objRS ("Title")
end if

if objRS("Title") = "" then
response.write "<br>~~No art matches search as entered~~<br>"
end if
do while not objRS.EOF
response.write "<TR>"
response.write "<TD><p>'" & objRS("Title") & "'</p></TD>"
response.write "<TD><p>" & objRS("Name")
"</p></TD>"
response.write "<TD><p>" & objRS("Date") & "</p></TD>"
if objRS("Type") = 1 then
strArtType = "Painting"
else
strArtType = "Sculpture"
end if
response.write "<TD><p>" & ">" & strArtType & "<" & "</p></TD>"
response.write "</TR>"
objRS.MoveNext
Loop
objRS.close
%>
 
S

Sebastian

Try this:

if objRS.EOF then
response.write "<br>~~No art matches search as entered~~<br>"
else
'do your while loop here
end if
 
S

Sebastian

or you can try this:

if isNull(objRS("Title")) then
response.write "Empty recordset"
end if

you can try isEmpty, but I think that my first reply objRS.EOF will work
just fine
 

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

Similar Threads

Urgent Help 0
No data return from ASP but Access returns correctly. 1
help with database driven cart 3
html message help 2
SQL script help 8
Help with my responsive home page 2
Help with code 0
Loop problem 2

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top