Ask a Question related to ASP Database, Design and Development.
-
Laphan #1
Problems check Array object status when using .GetRows
Hi All
I know the subject of this post might seem a bit cryptic, but I wanted to
get all of the keywords in.
Basically I'm using a combo of a local array var and GetRows to get my
recordset data and seems to work fine.
The only problem I have is that I know the main benefit of this GetRows is
to close the Recordset object as quick as poss, but using error checking on
an array doesn't seem to work as well. To explain my ramblings, I currently
use the following syntax:
.... connection stuff ...
.... command stuff ...
.... recordset stuff ...
' == I quickly get the recordset data into my array and close the object
IF NOT oRSv2.EOF THEN
arrSQLData = oRSv2.GetRows
END IF
oRSv2.close
' == I then check that the array is valid
IF IsArray(arrSQLData) THEN
..... do the recordset work
ELSE
.... no data available routine
END IF
This is where the problem seems to start, if there is no data then
arrSQLData generates an error because it was never defined as array in the
first place.
If I dim it as an array then it has the wrong initial parameters for the
variable data that GetRows puts into it and even if it did work then the
routine thinks it is an array which defeats the test.
At the moment, I've had to resort to using the following test instead:
oRSv.open oCmd
IF NOT oRSv.EOF THEN
arrSQLData = oRSv.GetRows
call BuildSearchResults()
ELSE
call NoSearchResults()
END IF
oRSv.close
But this then defeats the object (excuse the pun!!) of closing the recordset
object quickly because it has to go through the whole sub proc before it can
be closed.
Basically what I'm wanting to ask is what is the ipso facto code routine to
check whether any recordset data has come into the local array so that I can
do an IF.. THEN... ELSE on it.
PLEASE NOTE: another major problem of the above is that I generate the same
type of routine throughout a page to display different recordset data, which
can sometimes be 5 or 6 recordset calls to the same local var/array
(arrSQLData ) in one page. If for example, the 4th recordset doesn't
contain any data then the local var/array still passes the test because it
has the recordset data from the 3rd recordset. What's the best and most
efficient way to deal with this problem?
I know the above is a big ask, but I thank you in advance for any assistance
you can give.
Rgds
Laphan
Laphan Guest
-
Check status of FCS
Hello! I want to build a php-page that can check the status of a FCS-service. Like it is possible through the control panel. For example I... -
Problems returning an array in an object - Web Service
Ole Mugaas via .NET 247 <anonymous@dotnet247.com> wrote in news:OvAvlsUWFHA.2796@TK2MSFTNGP09.phx.gbl: Objects cant be returned over a soap... -
Check remote server status
My website redirect a certain page to another on an different server because that (generated) page is always up-to-date. Only that server isn't... -
how can i check and decide caps lock status
"gordonit" webforumsuser@macromedia.com wrote: Hi. Use this free xtra: http://www.scirius.com/HCommon/ExCL.htm -- Agustín María Rodríguez |... -
How to check the status of a DB2 Connection
We use DB2CLI. Does any one know if it is possible to check the status of a DB2 Connection (SQLHdbc) before actually using it. This will help in... -
Aaron [SQL Server MVP] #2
Re: Problems check Array object status when using .GetRows
If the rs is EOF, then the array is going to be empty. So your code could
look like this:
if rs.eof then
response.write "no data"
response.end
else
myArray = rs.GetRows()
... do stuff with array
end if
--
[url]http://www.aspfaq.com/[/url]
(Reverse address to reply.)
"Laphan" <news@DoNotEmailMe.co.uk> wrote in message
news:41038ecf$1_3@127.0.0.1...> Hi All
>
> I know the subject of this post might seem a bit cryptic, but I wanted to
> get all of the keywords in.
>
> Basically I'm using a combo of a local array var and GetRows to get my
> recordset data and seems to work fine.
>
> The only problem I have is that I know the main benefit of this GetRows is
> to close the Recordset object as quick as poss, but using error checking
> on
> an array doesn't seem to work as well. To explain my ramblings, I
> currently
> use the following syntax:
>
> ... connection stuff ...
> ... command stuff ...
> ... recordset stuff ...
>
> ' == I quickly get the recordset data into my array and close the object
>
> IF NOT oRSv2.EOF THEN
> arrSQLData = oRSv2.GetRows
> END IF
> oRSv2.close
>
> ' == I then check that the array is valid
>
> IF IsArray(arrSQLData) THEN
> .... do the recordset work
> ELSE
> .... no data available routine
> END IF
>
> This is where the problem seems to start, if there is no data then
> arrSQLData generates an error because it was never defined as array in the
> first place.
>
> If I dim it as an array then it has the wrong initial parameters for the
> variable data that GetRows puts into it and even if it did work then the
> routine thinks it is an array which defeats the test.
>
> At the moment, I've had to resort to using the following test instead:
>
> oRSv.open oCmd
> IF NOT oRSv.EOF THEN
> arrSQLData = oRSv.GetRows
> call BuildSearchResults()
> ELSE
> call NoSearchResults()
> END IF
> oRSv.close
>
> But this then defeats the object (excuse the pun!!) of closing the
> recordset
> object quickly because it has to go through the whole sub proc before it
> can
> be closed.
>
> Basically what I'm wanting to ask is what is the ipso facto code routine
> to
> check whether any recordset data has come into the local array so that I
> can
> do an IF.. THEN... ELSE on it.
>
> PLEASE NOTE: another major problem of the above is that I generate the
> same
> type of routine throughout a page to display different recordset data,
> which
> can sometimes be 5 or 6 recordset calls to the same local var/array
> (arrSQLData ) in one page. If for example, the 4th recordset doesn't
> contain any data then the local var/array still passes the test because it
> has the recordset data from the 3rd recordset. What's the best and most
> efficient way to deal with this problem?
>
> I know the above is a big ask, but I thank you in advance for any
> assistance
> you can give.
>
> Rgds
>
> Laphan
>
>
>
>
>
Aaron [SQL Server MVP] Guest
-
Laphan #3
Re: Problems check Array object status when using .GetRows
Hi Aaron
Can't do the response.end, because this call might be halfway through me
generating the page.
My condensed problems are:
1) How do I zap the local var/array before doing my routine? I can't use
Erase local var/array cos it might not be an array and therefore a tyoe
mismatch will come up.
2) If I did:
IF NOT oRSv.EOF THEN
oRSv.close
arrSQLData = oRSv.GetRows
call BuildSearchResults()
ELSE
oRSv.close
call NoSearchResults()
END IF
Would the new positioning of the oRSv.close free up the resources better
whilst not relying on my array check?
Rgds
Laphan
Aaron [SQL Server MVP] <ten.xoc@dnartreb.noraa> wrote in message
news:uvPryfjcEHA.3792@TK2MSFTNGP09.phx.gbl...
If the rs is EOF, then the array is going to be empty. So your code could
look like this:
if rs.eof then
response.write "no data"
response.end
else
myArray = rs.GetRows()
... do stuff with array
end if
--
[url]http://www.aspfaq.com/[/url]
(Reverse address to reply.)
"Laphan" <news@DoNotEmailMe.co.uk> wrote in message
news:41038ecf$1_3@127.0.0.1...> Hi All
>
> I know the subject of this post might seem a bit cryptic, but I wanted to
> get all of the keywords in.
>
> Basically I'm using a combo of a local array var and GetRows to get my
> recordset data and seems to work fine.
>
> The only problem I have is that I know the main benefit of this GetRows is
> to close the Recordset object as quick as poss, but using error checking
> on
> an array doesn't seem to work as well. To explain my ramblings, I
> currently
> use the following syntax:
>
> ... connection stuff ...
> ... command stuff ...
> ... recordset stuff ...
>
> ' == I quickly get the recordset data into my array and close the object
>
> IF NOT oRSv2.EOF THEN
> arrSQLData = oRSv2.GetRows
> END IF
> oRSv2.close
>
> ' == I then check that the array is valid
>
> IF IsArray(arrSQLData) THEN
> .... do the recordset work
> ELSE
> .... no data available routine
> END IF
>
> This is where the problem seems to start, if there is no data then
> arrSQLData generates an error because it was never defined as array in the
> first place.
>
> If I dim it as an array then it has the wrong initial parameters for the
> variable data that GetRows puts into it and even if it did work then the
> routine thinks it is an array which defeats the test.
>
> At the moment, I've had to resort to using the following test instead:
>
> oRSv.open oCmd
> IF NOT oRSv.EOF THEN
> arrSQLData = oRSv.GetRows
> call BuildSearchResults()
> ELSE
> call NoSearchResults()
> END IF
> oRSv.close
>
> But this then defeats the object (excuse the pun!!) of closing the
> recordset
> object quickly because it has to go through the whole sub proc before it
> can
> be closed.
>
> Basically what I'm wanting to ask is what is the ipso facto code routine
> to
> check whether any recordset data has come into the local array so that I
> can
> do an IF.. THEN... ELSE on it.
>
> PLEASE NOTE: another major problem of the above is that I generate the
> same
> type of routine throughout a page to display different recordset data,
> which
> can sometimes be 5 or 6 recordset calls to the same local var/array
> (arrSQLData ) in one page. If for example, the 4th recordset doesn't
> contain any data then the local var/array still passes the test because it
> has the recordset data from the 3rd recordset. What's the best and most
> efficient way to deal with this problem?
>
> I know the above is a big ask, but I thank you in advance for any
> assistance
> you can give.
>
> Rgds
>
> Laphan
>
>
>
>
>
Laphan Guest
-
Aaron [SQL Server MVP] #4
Re: Problems check Array object status when using .GetRows
> Can't do the response.end, because this call might be halfway through me
It was just an example. If it's rs.eof, then nothing in the else block gets> generating the page.
processed (could be the rest of the page).
A
Aaron [SQL Server MVP] Guest
-
Ken Schaefer #5
Re: Problems check Array object status when using .GetRows
Use isArray()
<%
If not objRS.EOF then
arrResults = objRS.GetRows
End If
objRS.Close
Set objRS = Nothing
'
'
'
'
'
If isArray(arrResults) then
' there were results before
Else
' there were no results before
End If
%>
Cheers
Ken
"Laphan" <news@DoNotEmailMe.co.uk> wrote in message
news:41038ecf$1_3@127.0.0.1...on> Hi All
>
> I know the subject of this post might seem a bit cryptic, but I wanted to
> get all of the keywords in.
>
> Basically I'm using a combo of a local array var and GetRows to get my
> recordset data and seems to work fine.
>
> The only problem I have is that I know the main benefit of this GetRows is
> to close the Recordset object as quick as poss, but using error checkingcurrently> an array doesn't seem to work as well. To explain my ramblings, Irecordset> use the following syntax:
>
> ... connection stuff ...
> ... command stuff ...
> ... recordset stuff ...
>
> ' == I quickly get the recordset data into my array and close the object
>
> IF NOT oRSv2.EOF THEN
> arrSQLData = oRSv2.GetRows
> END IF
> oRSv2.close
>
> ' == I then check that the array is valid
>
> IF IsArray(arrSQLData) THEN
> .... do the recordset work
> ELSE
> .... no data available routine
> END IF
>
> This is where the problem seems to start, if there is no data then
> arrSQLData generates an error because it was never defined as array in the
> first place.
>
> If I dim it as an array then it has the wrong initial parameters for the
> variable data that GetRows puts into it and even if it did work then the
> routine thinks it is an array which defeats the test.
>
> At the moment, I've had to resort to using the following test instead:
>
> oRSv.open oCmd
> IF NOT oRSv.EOF THEN
> arrSQLData = oRSv.GetRows
> call BuildSearchResults()
> ELSE
> call NoSearchResults()
> END IF
> oRSv.close
>
> But this then defeats the object (excuse the pun!!) of closing thecan> object quickly because it has to go through the whole sub proc before itto> be closed.
>
> Basically what I'm wanting to ask is what is the ipso facto code routinecan> check whether any recordset data has come into the local array so that Isame> do an IF.. THEN... ELSE on it.
>
> PLEASE NOTE: another major problem of the above is that I generate thewhich> type of routine throughout a page to display different recordset data,assistance> can sometimes be 5 or 6 recordset calls to the same local var/array
> (arrSQLData ) in one page. If for example, the 4th recordset doesn't
> contain any data then the local var/array still passes the test because it
> has the recordset data from the 3rd recordset. What's the best and most
> efficient way to deal with this problem?
>
> I know the above is a big ask, but I thank you in advance for any> you can give.
>
> Rgds
>
> Laphan
>
>
>
>
>
Ken Schaefer Guest
-
Chris Hohmann #6
Re: Problems check Array object status when using .GetRows
"Laphan" <news@DoNotEmailMe.co.uk> wrote in message
news:41038ecf$1_3@127.0.0.1...on> Hi All
>
> I know the subject of this post might seem a bit cryptic, but I wanted to
> get all of the keywords in.
>
> Basically I'm using a combo of a local array var and GetRows to get my
> recordset data and seems to work fine.
>
> The only problem I have is that I know the main benefit of this GetRows is
> to close the Recordset object as quick as poss, but using error checkingcurrently> an array doesn't seem to work as well. To explain my ramblings, Irecordset> use the following syntax:
>
> ... connection stuff ...
> ... command stuff ...
> ... recordset stuff ...
>
> ' == I quickly get the recordset data into my array and close the object
>
> IF NOT oRSv2.EOF THEN
> arrSQLData = oRSv2.GetRows
> END IF
> oRSv2.close
>
> ' == I then check that the array is valid
>
> IF IsArray(arrSQLData) THEN
> .... do the recordset work
> ELSE
> .... no data available routine
> END IF
>
> This is where the problem seems to start, if there is no data then
> arrSQLData generates an error because it was never defined as array in the
> first place.
>
> If I dim it as an array then it has the wrong initial parameters for the
> variable data that GetRows puts into it and even if it did work then the
> routine thinks it is an array which defeats the test.
>
> At the moment, I've had to resort to using the following test instead:
>
> oRSv.open oCmd
> IF NOT oRSv.EOF THEN
> arrSQLData = oRSv.GetRows
> call BuildSearchResults()
> ELSE
> call NoSearchResults()
> END IF
> oRSv.close
>
> But this then defeats the object (excuse the pun!!) of closing thecan> object quickly because it has to go through the whole sub proc before itto> be closed.
>
> Basically what I'm wanting to ask is what is the ipso facto code routinecan> check whether any recordset data has come into the local array so that Isame> do an IF.. THEN... ELSE on it.
>
> PLEASE NOTE: another major problem of the above is that I generate thewhich> type of routine throughout a page to display different recordset data,assistance> can sometimes be 5 or 6 recordset calls to the same local var/array
> (arrSQLData ) in one page. If for example, the 4th recordset doesn't
> contain any data then the local var/array still passes the test because it
> has the recordset data from the 3rd recordset. What's the best and most
> efficient way to deal with this problem?
>
> I know the above is a big ask, but I thank you in advance for anyYou need to do is declare arrSQLData as a variant because it could end up> you can give.
being an array or it could end up being "empty". I usually use something
like this:
<%
Dim cn, rs, arr, j, jMax
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open gstrConn 'Your DSNLess OLEDB Connection string here
cn.MyStoredProcedure Parameter1,Paramter2, ..., ParameterN, rs
If Not rs.EOF Then arr = rs.GetRows()
rs.Close : Set rs = Nothing
cn.Close : Set cn = Nothing
If IsArray(arr) Then
jMax = UBound(arr,2)
For j = 0 To jMax
'Do row processing here
Next
Else
'Report no data
End If
%>
Chris Hohmann Guest
-
Chris Hohmann #7
Re: Problems check Array object status when using .GetRows
"Astra" <info@NoEmail.com> wrote in message news:410f59fa$1_4@127.0.0.1...to> "Chris Hohmann" <nospam@thankyou.com> wrote in message
> news:%232YsztzcEHA.3476@tk2msftngp13.phx.gbl...
> "Laphan" <news@DoNotEmailMe.co.uk> wrote in message
> news:41038ecf$1_3@127.0.0.1...> > Hi All
> >
> > I know the subject of this post might seem a bit cryptic, but I wantedis> > get all of the keywords in.
> >
> > Basically I'm using a combo of a local array var and GetRows to get my
> > recordset data and seems to work fine.
> >
> > The only problem I have is that I know the main benefit of this GetRowsthe> on> > to close the Recordset object as quick as poss, but using error checking> currently> > an array doesn't seem to work as well. To explain my ramblings, I> > use the following syntax:
> >
> > ... connection stuff ...
> > ... command stuff ...
> > ... recordset stuff ...
> >
> > ' == I quickly get the recordset data into my array and close the object
> >
> > IF NOT oRSv2.EOF THEN
> > arrSQLData = oRSv2.GetRows
> > END IF
> > oRSv2.close
> >
> > ' == I then check that the array is valid
> >
> > IF IsArray(arrSQLData) THEN
> > .... do the recordset work
> > ELSE
> > .... no data available routine
> > END IF
> >
> > This is where the problem seems to start, if there is no data then
> > arrSQLData generates an error because it was never defined as array init> recordset> > first place.
> >
> > If I dim it as an array then it has the wrong initial parameters for the
> > variable data that GetRows puts into it and even if it did work then the
> > routine thinks it is an array which defeats the test.
> >
> > At the moment, I've had to resort to using the following test instead:
> >
> > oRSv.open oCmd
> > IF NOT oRSv.EOF THEN
> > arrSQLData = oRSv.GetRows
> > call BuildSearchResults()
> > ELSE
> > call NoSearchResults()
> > END IF
> > oRSv.close
> >
> > But this then defeats the object (excuse the pun!!) of closing the> can> > object quickly because it has to go through the whole sub proc before it> to> > be closed.
> >
> > Basically what I'm wanting to ask is what is the ipso facto code routine> can> > check whether any recordset data has come into the local array so that I> same> > do an IF.. THEN... ELSE on it.
> >
> > PLEASE NOTE: another major problem of the above is that I generate the> which> > type of routine throughout a page to display different recordset data,> > can sometimes be 5 or 6 recordset calls to the same local var/array
> > (arrSQLData ) in one page. If for example, the 4th recordset doesn't
> > contain any data then the local var/array still passes the test becauseI have no idea what you're doing wrong since I can't see the code you are> assistance> > has the recordset data from the 3rd recordset. What's the best and most
> > efficient way to deal with this problem?
> >
> > I know the above is a big ask, but I thank you in advance for any>> > you can give.
> You need to do is declare arrSQLData as a variant because it could end up
> being an array or it could end up being "empty". I usually use something
> like this:
>
> <%
> Dim cn, rs, arr, j, jMax
> Set cn = CreateObject("ADODB.Connection")
> Set rs = CreateObject("ADODB.Recordset")
> cn.Open gstrConn 'Your DSNLess OLEDB Connection string here
> cn.MyStoredProcedure Parameter1,Paramter2, ..., ParameterN, rs
> If Not rs.EOF Then arr = rs.GetRows()
> rs.Close : Set rs = Nothing
> cn.Close : Set cn = Nothing
>
> If IsArray(arr) Then
> jMax = UBound(arr,2)
> For j = 0 To jMax
> 'Do row processing here
> Next
> Else
> 'Report no data
> End If
> %>
>
> Hi Chris
>
> I have declared it as a variant, so what am I doing wrong?
>
> What about the erase bit as well?
>
> Rgds
>
> Robbie
using. Please post the code. Also, please post your responses below the
quoted material or interlaced. Placing your response at the top makes it
very difficult to follow the thread of the discussion.
Chris Hohmann Guest



Reply With Quote

