How do I test the status of a GetRows populated var

How do I test the status of a GetRows populated var

am 24.11.2004 18:18:14 von Laphan

The below example is a typical example of the problems I am experiencing
with something that is probably very easy to resolve, but I just can't do
it:

Dim arrCheckMatrix

' == check if any selected players are injured

strSQL = "select MYNAME from MYTABLE where MYFLAG=1"

arrCheckMatrix = DBQueryToArray(strSQL) <<< all this bit does is make
arrCheckMatrix the result of
a
..GetRows from the above query

If the above query does retrieve a row of data then all is fine. It will do
what I want.

However all I want is a simple test to say if arrCheckMatrix is empty, ie no
rows where returned then do this... else do this...

If XXXXXXXX Then << what test do I put here?
response.write "Invalid Selection"
Else
response.write "valid Selection"
End If

Can u help?

Rgds Mac

Re: How do I test the status of a GetRows populated var

am 29.11.2004 02:24:51 von unknown

IsEmpty should work, depending on how your DBQueryToArray function is
structured.

Function DBQueryToArray(sql)
'''code to open db
Set oRS = yourConnection.Execute(sql)
If Not oRS.EOF Then DBQueryToArray = oRS.GetRows()
''clean up
End Function

As you can see, DBQueryToArray may never have a value assigned to it, so
IsEmpty would work.

Ray at home

"Macsicarr" wrote in message
news:OwHV9jk0EHA.3448@TK2MSFTNGP09.phx.gbl...
> The below example is a typical example of the problems I am experiencing
> with something that is probably very easy to resolve, but I just can't do
> it:
>
> Dim arrCheckMatrix
>
> ' == check if any selected players are injured
>
> strSQL = "select MYNAME from MYTABLE where MYFLAG=1"
>
> arrCheckMatrix = DBQueryToArray(strSQL) <<< all this bit does is make
> arrCheckMatrix the result of
> a
> .GetRows from the above query
>
> If the above query does retrieve a row of data then all is fine. It will
> do
> what I want.
>
> However all I want is a simple test to say if arrCheckMatrix is empty, ie
> no
> rows where returned then do this... else do this...
>
> If XXXXXXXX Then << what test do I put here?
> response.write "Invalid Selection"
> Else
> response.write "valid Selection"
> End If
>
> Can u help?
>
> Rgds Mac
>
>

Re: How do I test the status of a GetRows populated var

am 29.11.2004 16:19:37 von reb01501

Sorry to reply to you Ray. I don't see the original post in OE, so I can't
reply to it.

Depending on what DBQueryToArray is doing, you can use the IsArray function.

dim rs, ar
set rs=conn.execute(strsql,,1)
if not rs.eof then ar=rs.getrows
rs.close:set rs=nothing
if isArray(ar) then
...
else
'rs was empty
end if

Bob Barrows

Ray Costanzo [MVP] wrote:
> IsEmpty should work, depending on how your DBQueryToArray function is
> structured.
>
> Function DBQueryToArray(sql)
> '''code to open db
> Set oRS = yourConnection.Execute(sql)
> If Not oRS.EOF Then DBQueryToArray = oRS.GetRows()
> ''clean up
> End Function
>
> As you can see, DBQueryToArray may never have a value assigned to it,
> so IsEmpty would work.
>
> Ray at home
>
> "Macsicarr" wrote in message
> news:OwHV9jk0EHA.3448@TK2MSFTNGP09.phx.gbl...
>> The below example is a typical example of the problems I am
>> experiencing with something that is probably very easy to resolve,
>> but I just can't do it:
>>
>> Dim arrCheckMatrix
>>
>> ' == check if any selected players are injured
>>
>> strSQL = "select MYNAME from MYTABLE where MYFLAG=1"
>>
>> arrCheckMatrix = DBQueryToArray(strSQL) <<< all this bit does is
>> make arrCheckMatrix the result of
>>
>> a .GetRows from the above query
>>
>> If the above query does retrieve a row of data then all is fine. It
>> will do
>> what I want.
>>
>> However all I want is a simple test to say if arrCheckMatrix is
>> empty, ie no
>> rows where returned then do this... else do this...
>>
>> If XXXXXXXX Then << what test do I put here?
>> response.write "Invalid Selection"
>> Else
>> response.write "valid Selection"
>> End If
>>
>> Can u help?
>>
>> Rgds Mac

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.