L
Laphan
Hi All
I'm using .getRows() with a local var array instead of doing a recursive
loop so that I'm being a good ASP newvbie and closing my object i/o's (the
recordset in this case) as quick as possible.
My problem is that I can't seem to use this to complete good effect because
the IsArray statement doesn't seem to work with a local var array that has
or has not been populated with the .getRows() property.
To explain, I used to do the following recursive loop (simplified to show a
concise example):
.... create/open objects
IF NOT oRSv.EOF THEN
Do while not oRSv.EOF and not ii > cMax
Response.Write "<TR><TD>" & oRSv("Product") & "</TD></TR>"
oRSv.MoveNext
ii = ii + 1
Loop
END IF
.... close objects
I was told that the above is a bit of a resource hogger because I am
constantly calling the object and leaving it open whilst I do the loop, so I
moved on to using the .GetRows() method. This does seem quicker, but the
following has a problem if the recordset basically doesn't bring anything
back:
IF NOT oRSv.EOF THEN arrSQLData = oRSv.GetRows
oRSv.close
IF IsArray(arrSQLData) THEN << SEE *** BELOW
call ShowAboutUsContent()
ELSE
call NoAboutUsContent()
END IF
*** = if there is nothing in the oRSv.GetRows the IsArray() test still goes
through as true and then fouls up the 'ShowAboutUsContent()' sub because
there is nothing to display. I want to use this quick and easy test because
it is clean and easy to read, ie if there is some content then do
ShowAbout... sub if not then do NoAboutUs..., but this test doesn't seem to
work. To get round this for now I have had to do the following:
IF NOT oRSv.EOF THEN
arrSQLData = oRSv.GetRows
call ShowAboutUsContent()
ELSE
call NoAboutUsContent()
END IF
oRSv.close
Although the above works I'm not being efficient because one of the above
subs has to go through to completion before I can close the oRSv.close (in
this case).
Can somebody explain what I am doing wrong with the IsArray. Am I using it
in the way that it is intended?
Thanks
Laphan
I'm using .getRows() with a local var array instead of doing a recursive
loop so that I'm being a good ASP newvbie and closing my object i/o's (the
recordset in this case) as quick as possible.
My problem is that I can't seem to use this to complete good effect because
the IsArray statement doesn't seem to work with a local var array that has
or has not been populated with the .getRows() property.
To explain, I used to do the following recursive loop (simplified to show a
concise example):
.... create/open objects
IF NOT oRSv.EOF THEN
Do while not oRSv.EOF and not ii > cMax
Response.Write "<TR><TD>" & oRSv("Product") & "</TD></TR>"
oRSv.MoveNext
ii = ii + 1
Loop
END IF
.... close objects
I was told that the above is a bit of a resource hogger because I am
constantly calling the object and leaving it open whilst I do the loop, so I
moved on to using the .GetRows() method. This does seem quicker, but the
following has a problem if the recordset basically doesn't bring anything
back:
IF NOT oRSv.EOF THEN arrSQLData = oRSv.GetRows
oRSv.close
IF IsArray(arrSQLData) THEN << SEE *** BELOW
call ShowAboutUsContent()
ELSE
call NoAboutUsContent()
END IF
*** = if there is nothing in the oRSv.GetRows the IsArray() test still goes
through as true and then fouls up the 'ShowAboutUsContent()' sub because
there is nothing to display. I want to use this quick and easy test because
it is clean and easy to read, ie if there is some content then do
ShowAbout... sub if not then do NoAboutUs..., but this test doesn't seem to
work. To get round this for now I have had to do the following:
IF NOT oRSv.EOF THEN
arrSQLData = oRSv.GetRows
call ShowAboutUsContent()
ELSE
call NoAboutUsContent()
END IF
oRSv.close
Although the above works I'm not being efficient because one of the above
subs has to go through to completion before I can close the oRSv.close (in
this case).
Can somebody explain what I am doing wrong with the IsArray. Am I using it
in the way that it is intended?
Thanks
Laphan