Forums

This topic is locked

Error handling

Posted 28 Jun 2002 19:14:48
1
has voted
28 Jun 2002 19:14:48 Virginia Older posted:
I was wondering if anyone new a good way to deal with an empty recordset throwing an error. I can only seem to find tutorials on when the page actually displays with no records, but mine shows and error saying the BOF or EOF is true? Any ideas?
Thanks!
Va.

Replies

Replied 28 Jun 2002 19:22:22
28 Jun 2002 19:22:22 aegis kleais replied:
Absolutely!

The only reason you're getting that error is NOT because you have a recordset that returns no records, it's that you're trying to DISPLAY that info on the page when there is no info.

Highlite the text that displays the database info and use a SHOW REGION > If Recordset is NOT empty. And select the recordset.

But you'll want to tell people that there is no data rather then have it sit there blankly.

So make text that says "Hey there shiznits, there's no data in this recordset" Highlite it and then apply a SHOW REGION > If Recordset IS empty. And select the recordset.

BOO BAM!
Replied 28 Jun 2002 19:50:49
28 Jun 2002 19:50:49 Virginia Older replied:
It didn't work. Apparently, because I have 6 recordsets on one page, using layers to disply them depending on user events, it isn't working. Maybe because I have each recordset spawning off of the forst one, which spawns off of a form? I dunno. Thanks though!
Va <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Replied 28 Jun 2002 19:55:54
28 Jun 2002 19:55:54 aegis kleais replied:
!!!???

Well, I don't know about the layers and all, but I have pages with 5+ recordsets on it as well, and as long as you add the SHOW REGION &gt; If Recordset is NOT empty (and then select the proper recordset you're refering to after that), everything worked on my system. What's the exact error you're getting now? Does the error tell you which recordset produced the EOF/BOF? What's the lines of code around where the error occured? (Check for the error line #)
Replied 28 Jun 2002 20:21:20
28 Jun 2002 20:21:20 Virginia Older replied:
I dunno..I put it on every place where records will be displayed and put the corresponding rs with the display fields.

ADODB.Field error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/ASP/TMP8b0niyfi06.asp, line 29

line 24-42 is as follows...
&lt;%
//Start all ASP server functions for the Location Tab on Documents
//This includes the recordset and the Record Navigation Function

var rsDocLoc__LocVar = "1";
if(String((rsDoc.Fields.Item("LocID".Value)) != "undefined" {
rsDocLoc__LocVar = String((rsDoc.Fields.Item("LocID".Value));
}
%&gt;
&lt;%
var rsDocLoc = Server.CreateObject("ADODB.Recordset";
rsDocLoc.ActiveConnection = MM_JSIPS_STRING;
rsDocLoc.Source = "SELECT Loc_Code, Name, Location, doc_location, DocDate, DocSerNo FROM tblLoc INNER JOIN tblDocLoc ON tblLoc.LocationID = tblDocLoc.LocID WHERE tblDocLoc.LocID = "+ rsDocLoc__LocVar.replace(/'/g, "''" + " ORDER BY DocDate, doc_location";
rsDocLoc.CursorType = 0;
rsDocLoc.CursorLocation = 2;
rsDocLoc.LockType = 3;
rsDocLoc.Open();
var rsDocLoc_numRows = 0;
%&gt;

Sorry, if I am doing something silly. I can't tell!
Replied 28 Jun 2002 20:46:23
28 Jun 2002 20:46:23 aegis kleais replied:
rsDocLoc__LocVar = String((rsDoc.Fields.Item("LocID".Value));

Ok, that's line 29. Let's be systematic about this.

Is the recordset called rsDoc? (I dont' know if you handcoded this or not)
Is there a field called LocID? (I dont' know if you handcoded this or not)
Is the database populated right now?

Try removing the STRING function off the field and then recheck to see if the "SHOW REGION IF RECORDSET IS NOT EMPTY" works.

With some systematic testing, we can see what's causing the problem and go from there
Replied 30 Jun 2002 02:03:09
30 Jun 2002 02:03:09 Virginia Older replied:
Well, the recordset is empty... but what if the user wants to check on a certain thing and the recordset is empty...i want them to get a custom page not the one that is now displaying. So i was hoping there would be an easy way to do this, kind of like the "If recordset is empty" server behavior. But alas...it won't seem to work with my pages... <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle> I'll figure it out hopefully..maybe a javascript.
Replied 30 Jun 2002 06:15:28
30 Jun 2002 06:15:28 aegis kleais replied:
Well, if you're looking for a "IF RECORDSET IS EMPTY, GO HERE" deal, the code should be:

(assuming you created a recordset called rcdUsers)


IF rcdUsers.BOF OR rcdUsers.EOF then Response.Redirect("page.asp"

This basically says "If recordset is at begining of file or end of file (which it will be if it's empty, cause nothing exists) then goto page.asp
Replied 01 Jul 2002 02:19:56
01 Jul 2002 02:19:56 Virginia Older replied:
Sorry if this is simple, but would I code as part of the ASP or js in the head section? i thank you for all of your help!
Replied 01 Jul 2002 04:05:10
01 Jul 2002 04:05:10 aegis kleais replied:
ASP is rendered "real time" on the server before it is spat back to the browser. IE, when you request an ASP page, the server reads the full asp information and html in the file, creates the entire page and then returns it to the user. For the most part, only header related coding or information that needs to be assigned or performed before the page is returned will be coded before the &lt;html&gt; code.

Remember, this is not ASP or Javascript code.....ASP can be created by a PLETHORA of languages, the most popular of which is VBscript, and then Javascript...

The general format for a page would be

&lt;% @LANGUAGE=VBSCRIPT %&gt;
&lt;% ' ASP code goes up here before html %&gt;
&lt;html&gt;
&lt;% ' however, ASP code can go here too; it's just rendered before the the page is returned to the user %&gt;
&lt;b&gt;other html code can go here&lt;/b&gt;
&lt;/html&gt;
&lt;% ' ASP can go here to, but it won't get sent to the user cause you ended the html %&gt;

Reply to this topic