Forum Moderators: open

Message Too Old, No Replies

Checking for empty after calling getRows

         

aspdaddy

9:02 am on Sep 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Im using this function below to get large data sets data from a database into arrays. Problem is I need to check for an empty array back in the main program.

I coded the function to return -1 for an empty set but am having problems comparing the array to -1, any better solutions?
Thanks

' asp page
arrData = getArray ("exec dbo.getUsers " & strIP)
if arrData <> -1 then
' display users
end if

' include function
public function getArray ( strSQL )
dim objConn,objRS, arrTemp
set objConn=Server.CreateObject("ADODB.Connection")
openDB( objConn )
set objRS=objConn.Execute( strSQL )
if not objRS.EOF then
arrTemp = objRS.GetRows()
else
arrTemp=-1
end if
closeRS(objRS)
closeDB(objConn)
getArray = arrTemp
end function

Easy_Coder

4:37 pm on Sep 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I usually set the array to null

if not objRS.EOF then
arrTemp = objRS.GetRows()
else
arrTemp=null
end if

myarray = getArray ( strSQL )
if not isnull(myarray) then
'unwind it
end if

TheNige

7:53 pm on Sep 6, 2006 (gmt 0)

10+ Year Member



You can also you the IsArray function

If IsArray(yourArray) Then

End If