Cable Forum

Cable Forum (https://www.cableforum.uk/board/index.php)
-   General IT Discussion (https://www.cableforum.uk/board/forumdisplay.php?f=19)
-   -   ASP Problem (https://www.cableforum.uk/board/showthread.php?t=12000)

gazzae 06-05-2004 15:20

ASP Problem
 
Hi,

I have an ASP page that I created. It opens a recordset, and puts the values into an array using getrows.

There are only two records in the database. (access)

Now the problem is that when I get the ubound of the array, instead of returning 1 - which would be correct, it returns 3.... this means I get a error when the page tries to display 2 and 3 as they do not exist.

Anyone got any ideas? My Code is below..

Code:

<%

if Session("firstrun") = 0 then

                set dataconnection = server.CreateObject ("ADODB.CONNECTION")       
                set datacommand = server.CreateObject ("ADODB.Command")
                set recordset = server.CreateObject ("ADODB.recordset")
                dataconnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=demo.mdb;"
                dataconnection.Open
                datacommand.ActiveConnection = DataConnection
                txtsql = "SELECT * FROM mess"
                datacommand.CommandText = txtsql
                recordset.Open datacommand
                dim myarray
                myarray = recordset.GetRows
                RecordSet.Close
                Set RecordSet = Nothing
                Set datacommand = Nothing
                DataConnection.Close
                Set DataConnection = Nothing
                Session("firstrun") = 1
else
        myarray = Session("myarray1")
        i = session("i")
end if
%>

<%
response.write "Ubound"
response.write ubound(myarray)
response.write "<BR>"
if i > ubound(myarray) then
                session("firstrun")= 0
else
        response.write myarray(0,i)
        response.write myarray(1,i)
        response.write myarray(2,i)
        response.write myarray(3,i)
        response.write session("firstrun")
        response.write session("i")
        i = i +1
        session("i") = i
end if
%>


gazzae 07-05-2004 12:58

Re: ASP Problem
 
DOH!!! I'm so stupid!

Because its a 2d array I should have got the Ubound by using - Ubound(myarray, 2)

It works now!


All times are GMT. The time now is 11:06.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum