Classic ASP DatabasesDiscuss 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I've put together a little piece of code to allow a user to search a website for properties to rent or buy against a set of locations (pulled from the database).
what I'm finding is that I have error handling issues when say a search is made for rental properties against a town for which I don't have a rental property (but I do have a property in the database, for sale).
because the locations are pulled from the database to populate the select option box, they are all genuine records but, the locations don't always have properties for sale and for rent so that occasionally I get a "EOF or BOF" error.
I'm just looking for some ideas as to how I could possibly handle the situation gracefully. I was thinking of using some AJAX techniques to get the select option box to re-populate after the user changes the selection on the 'rent or buy' drop-down box, but this seems quite complicated and I'm sure there is an easier ASP solution to this.
IF rentval <> TRUE THEN rentval="for sale" ELSE rentval="for rent" END IF
<br />Ref: <%=propID%>, postcode: <%=pstcode%><br />Town: <%=proparea%>, <%=borName%><br />nearest tube: <%=tstn%><br />Bedrooms: <%=bedNo%><br />Reception Rooms: <%=RecepNo%><br />This property is <strong><%=rentval%></strong><%=priceType%> <strong><% IF mthlys <> 0 THEN response.Write(mthlys) END IF %><% IF valPrice <> 0 THEN response.write(valPrice) END IF %></strong>
<% RSobj.MoveNext %>
I was too focused on the idea of "Error handling", should have concentrated on the actual nature of the error in question, the BOF/EOF thing.
just set up an IF THEN ELSE to capture the rs before it executed and give a graceful error message and some links back to the site, in the event of there not being a record in existence matching the criteria set by the user.
I was faced with the same issue on a site that had equipment for sale and for rent. What I did was only populate the drop-down if there was equipment for rent or sale in that category. So, in your case, with this logic, the town just wouldn't show up. As long as you got it fixed and its working. That's good. I like it when stuff works.
I thought about doing that, just adding another condition onto the sql behind the drop box but, I needed to have all the offerings available via the quicksearch.
by creating an bof|eof handling variable, I'm able to inform the user about the reason why the particular search combination failed as well as present them with other options.
I was thinking about putting together a series of LIKE "x%" tests against the recordset, then presenting them as potentially satisfying alternatives, because in most cases a person will desire a property to be in either a specific area and to a less specific size ... so if I had a 3 bedroom property and not a 4 bedroom one... it might be of benefit to the user to be shown it.
I guess everyone has their own way. I just wouldn't like to keep getting dead end search results after choosing my filters... too frustrating. Let me know how you're LIKE statements work out. Good luck with it.