Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 3rd, 2003, 01:29 PM
Authorized User
 
Join Date: Jul 2003
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default if search comes up empty

How can I tell if a search on the db comes up empty so I can handle it?

 
Old October 4th, 2003, 02:23 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Are you using ASP with ADO and use a recordset to get the data from your database? You're not providing much information about your situation, so I'll assume the above is true.

In this case, you can use the .EOF (End Of File) property of the recordset:
Code:
' Create and open recordset here
If Not MyRecordset.EOF Then
  ' Do something with the records
Else
  Response.Write("Sorry, no records found")
End If
Does this help?

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old October 4th, 2003, 03:58 AM
Authorized User
 
Join Date: Sep 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zaeem Send a message via Yahoo to zaeem
Default

Hello ur answer benefited me a lot. If I want to check that my recordset returns Null I want to check it within the <% do while not r.eof%> how can I check it out here.Waiting to have reply.
Bye

Zaeem Sherazi
 
Old October 4th, 2003, 04:45 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Well, you can check for EOF first, and if the recordset is not EOF, do your While loop:
Code:
' Create and open recordset here
If Not MyRecordset.EOF Then
  Do While Not MyRecordset.EOF
    ' Do something with the record from the recordset
    Response.Write("Value is " & MyRecordset("MyColumn"))
    ' Move to the next record
    MyRecordset.MoveNext()
  Loop
Else
  Response.Write("Sorry, no records found")
End If
HtH,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Search button doesn't search Access DB cbones Visual Studio 2008 1 October 27th, 2008 07:36 PM
New text search doesn't preselect search string planoie Visual Studio 2005 0 July 23rd, 2007 06:47 AM
File Search / Indexing Search with .net 2.0 maulik77 ASP.NET 1.0 and 1.1 Basics 2 March 15th, 2007 12:45 AM
Search Engine for Full-text Search Kala ASP.NET 1.0 and 1.1 Professional 2 August 29th, 2004 02:16 AM
search for null /String.Empty in Active Directory georgeh C# 1 October 16th, 2003 08:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.