Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type mismatch: 'UBOUND'

Status
Not open for further replies.

aitai

MIS
Jul 3, 2001
36
US
Hi, All

I am losing my hair here! And, would greatly appreciate some insight into this error:

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'UBOUND'

I have searched high and low with out progress. I am using Oracle 8.1.7, the table(Destination) has 2 columns(DestinationID[CHAR3],Country[VARCHAR20]) Thanks in advance! The code:

<% @ language=&quot;vbscript&quot; %>
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>

<html>
<head>
<title>Using an Array With a Recordset</title>
</head>
<body>
<center>
<h2>Using an Array With a Recordset</h2>
</center>
<%
DIM oDBConnection,oRecordSet,oArray

SET oDBConnection = SERVER.CREATEOBJECT(&quot;ADODB.Connection&quot;)
oDBConnection.Open &quot;dsn=OraDev;UID=scott;PWD=tiger;&quot;

'the following creates a recordset object and recordset at the same time
SET oRecordSet = oDBConnection.EXECUTE(&quot;SELECT * FROM Destination&quot;)

'if there are any records in the recordset, use the getrows method to
'insert inot array
IF NOT oRecordSet.EOF AND oRecordSet.BOF THEN
oArray=oRecordSet.GetRows( )
END IF
%>

<table>
<%
FOR iRow=0 TO UBOUND(oArray,2)
%>
<tr>
<%
FOR jCol=0 TO 1
%>
<td>
<%= oArray(jCol,iRow) %>
</td>
<% NEXT %>
</tr>
<% NEXT %>
</table>
</body>

</html>
 
From the sound of the error and looking at your code, it looks like the recordset is not getting created. Have you tried printing out the recordset before you assign it to an array - or even just add an else clause to test it out:

if oRecordSet.BOF then
Response.Write &quot;There are no records in the recordset&quot;
Response.End
else
oArray=oRecordSet.GetRows()
END IF

Mise Le Meas,

Mighty :)
 
I think this line:
IF NOT oRecordSet.EOF AND oRecordSet.BOF THEN
should be like this:
IF NOT (oRecordSet.EOF AND oRecordSet.BOF) THEN

I used your code and just changed the connection string and changed that line.
That fixed the problem for me.
Before this line:
FOR iRow=0 TO UBOUND(oArray,2)
You should put the if statement again
IF NOT (oRecordSet.EOF AND oRecordSet.BOF) THEN
and after the last next line you should put:
ELSE
Response.write &quot;no records found&quot;
END IF
 
i echo the above. i use GetRows frequently and have run into that problem when i didn't check that there was anything in my recordset first.

good luck with your coding!

(-:
 
Thanks, All

You advice did the trick-much appreciated!

Ivan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top