Microsoft VBScript runtime error '800a0005'

G

Guest

I just realized that, if my ASP has no records the page doesn't open. I get
the error message:

Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument

/BIE/BIEmotor/43001000-8001/43001000-9000/optionopenorders430010009000.asp,
line 61

Can someone tell me how to avoid that?

My line 61 is in between the ***************:

<%
RS.Open SQL, MyConn, adOpenStatic, adLockReadOnly, adCmdText

Page_Count = RS.PageCount

If 1 > Current_Page Then Current_Page = 1
If Current_Page > Page_Count Then Current_Page = Page_Count

************RS.AbsolutePage = Current_Page*******************

Do While RS.AbsolutePage = Current_Page AND Not RS.EOF
%>
 
D

David Berry

You need to check for an empty result set earlier in your code. Ex:

if RS.EOF or RS.BOF then
Response.Write "There are no more records"
else
...............

end if
 
M

Mark Fitzpatrick

You'll always want to check for two things. First check to ensure that you
are not working with a null object

IF Not(isNothing(RS))

I believe that's the syntax though it's been 6 or 7 years since I worked
with classic ASP. Even if the recordset is not nothing you still need to
check to see if there is data. To do this, ensure that the recordset is not
set to both BOF and EOF. When it's empty this condition will be true

IF NOT(RS.BOF AND RS.EOF)
 
S

Stefan B Rusynko

Are all the variables defined someplace for this line
- if so what are they

RS.Open SQL, MyConn, adOpenStatic, adLockReadOnly, adCmdText

--




|I just realized that, if my ASP has no records the page doesn't open. I get
| the error message:
|
| Microsoft VBScript runtime error '800a0005'
|
| Invalid procedure call or argument
|
| /BIE/BIEmotor/43001000-8001/43001000-9000/optionopenorders430010009000.asp,
| line 61
|
| Can someone tell me how to avoid that?
|
| My line 61 is in between the ***************:
|
| <%
| RS.Open SQL, MyConn, adOpenStatic, adLockReadOnly, adCmdText
|
| Page_Count = RS.PageCount
|
| If 1 > Current_Page Then Current_Page = 1
| If Current_Page > Page_Count Then Current_Page = Page_Count
|
| ************RS.AbsolutePage = Current_Page*******************
|
| Do While RS.AbsolutePage = Current_Page AND Not RS.EOF
| %>
 
G

Guest

I don't find that at all in my code. Do I have to insert your piece
somewhere? If yes, can you tell me where?

I think it's better if I send the code:

<%@ Language=VBScript %>
<% Option Explicit %>

<% Response.Buffer = True %>
<!-- #include file="adovbs.inc" -->

<html>
<body class="formpage" style="background-color: #DFDFDF" topmargin="6"
leftmargin="0" rightmargin="0" bottommargin="0">
<table width="552" border="0">
<tr>

<td align="left" valign="top" height="14" width="548"><img border="0"
src="http://www.myweb.com/BIE/images/c1_top.GIF" width="547" height="14"></td>
</tr>

</tr>
</table>
<%
Dim Connect_String
Dim Page_Size 'variable which holds the number of records to be viewed per
page.
Dim Current_Page 'variable which keeps track of which page is the current
page.
Dim MyConn
Dim RS
Dim SQL
Dim Page_Count 'variable which stores the number of pages that can be viewed.
Dim Form


'if using SQL Server then use
Connect_String = "DSN=access;Database=f:www.myweb.com\Data\transferdb.mdb"
'if using DSN-Less then use
Connect_String = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" &
Server.MapPath("webopenoptionorders430010009000")
'if using DSN then use
Connect_String = "DSN=access;Database=f:www.myweb.com\Data\transferdb.mdb"

Page_Size = 1 'here we set the number of records viewed per page to 15.

If Request("Page")="" Then
Current_Page = 1
Else
Current_Page = CInt(Request("Page")) 'the CInt function converts the value
to an integer.
End If

Set MyConn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.RecordSet")
MyConn.Open Connect_String

RS.CursorLocation = adUseClient
RS.PageSize = Page_Size

'below change the statement to reflect your query
SQL = "SELECT * FROM webopenoptionorders430010009000"
%>
<%
RS.Open SQL, MyConn, adOpenStatic, adLockReadOnly, adCmdText

Page_Count = RS.PageCount

If 1 > Current_Page Then Current_Page = 1
If Current_Page > Page_Count Then Current_Page = Page_Count

RS.AbsolutePage = Current_Page
Do While RS.AbsolutePage = Current_Page AND Not RS.EOF
%>

<table width="552">
<tr>
<td align="left" valign="top" class="formpagetablelabel"
style="text-align: left; font-family: Tahoma; font-size: 8pt;"
width="247"> Fecha</td>
<td width="295"><input class="formpagetablefield" type="text"
style="text-align: right; font-family: Tahoma; font-size: 8pt;" name="fecha"
size="50" Value="<%=trim(rs("fecha"))%>"></td>
</tr>
***********MORE RECORDS ARE SHOWN********************
</table>
<p align="center">
<table width="552" border="0">
<%
RS.MoveNext
Loop

'clean up
RS.Close
Set RS = Nothing
MyConn.Close
Set MyConn = Nothing

Response.Write "<br>"

If Current_Page <> 1 Then
Response.Write%><form method="Post"
action="http://www.MYWEB.com/BIE/BIEmotor/43001000-8001/43001000-9000/optionopenorders430010009000.asp?Page=<%=Current_Page
- 1 %>"style="text-align: center"><input type="submit" value="<< registro
anterior" name="btnnext" class="formpagebutton">
</form>
<%
End If
If Current_Page < Page_Count Then
Response.Write%><form method="Post"
action="http://www.MYWEB.com/BIE/BIEmotor/43001000-8001/43001000-9000/optionopenorders430010009000.asp?Page=<%=Current_Page
+ 1 %>"style="text-align: center"><input type="submit" value="después
registro >>" name="btnnext" class="formpagebutton">
<%
End If
%>
</p></table>
</body>
</html>
 
D

David Berry

adOpenStatic, adLockReadOnly and adCmdText aren't variables that need to be
defined. They're ADO constants that are defined in the adovbs.inc file
already. Also, defining your variables is a goof thing but it would be
causing that error.
 
G

Guest

Hi David
I got the scelleton of this script from one of your guys. I managed to get
it working except that it's not opening if there is no data in my DB.
I realized that my knowledge is not far enough to repair that what I need by
myself. Is it possible for you to tell me exactly what I have to do? If you
do not wish to help me further I would understand that as well, because I
know how difficult it is to work with an amateur who only understands if
everything is explained 10times.
Thanks
Klaus
 
D

David Berry

After the line that says:

RS.Open SQL, MyConn, adOpenStatic, adLockReadOnly, adCmdText

Put

IF NOT(RS.BOF AND RS.EOF)

then at the end of all your code put

END IF
 
G

Guest

Yuppppeeeeee, it's working - you were a great (even bigger) help.
I thank you so much. IT IS WORKING.
Please, just do me one favour (so that I understand a bid), can you explain
to me what this line is doing?
IF NOT(RS.BOF AND RS.EOF)Then
If it takes too much time than just forget it.
Regards
Klaus
 
D

David Berry

RS is the name of your recordset (all the data being pulled in from the
database). EOF is End of File and BOF is Beginning of file.

What the line is saying is if your recordset is NOT at the beginning or end
of the file (if there are no records) then do what comes next otherwise
stop. It's always a good idea to do this because you may get a case where
your recordset is empty - has no records - and you don't want to process the
rest of the code.
 
B

Bob Lehmann

It is not necessary to check both BOF and EOF. Just checking EOF is
sufficient.

Bob Lehmann
 

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

Top