|
 |
access_asp thread: rst.recordCount returns -1
Message #1 by Ping Li <pli@l...> on Fri, 22 Feb 2002 13:39:43 -0600
|
|
I was trying to find the total number of the records. But it returns -1. Can
anybody tell me what's wrong with my codes?
Thanks a lot.
Ping
<%
dim rst, id
id = request.queryString("id")
set rst = Server.CreateObject("ADODB.Recordset")
sqlString = "exec sprInfo " & id
set rst = objConnection.execute (sqlString)
numOfRecords = rst.RecordCount
%>
Message #2 by Thomas Bellavia <TBellavia@V...> on Fri, 22 Feb 2002 15:14:26 -0500
|
|
Did you do a: if( rst.State == adStateOpen ) to see if it indeed did?
-----Original Message-----
From: Ping Li [mailto:pli@l...]
Sent: Friday, February 22, 2002 2:40 PM
To: Access ASP
Subject: [access_asp] rst.recordCount returns -1
I was trying to find the total number of the records. But it returns -1. Can
anybody tell me what's wrong with my codes?
Thanks a lot.
Ping
<%
dim rst, id
id = request.queryString("id")
set rst = Server.CreateObject("ADODB.Recordset")
sqlString = "exec sprInfo " & id
set rst = objConnection.execute (sqlString)
numOfRecords = rst.RecordCount
%>
Message #3 by Ping Li <pli@l...> on Fri, 22 Feb 2002 14:18:59 -0600
|
|
Hi, Thomas,
I am new to ASP so I am not familiar with your code. But I am sure the
recordset is open since I can retrieve individual record. I just couldn't
get the right number of total records. adOpenStatic doesn't work when I use
objConnection.execute.
-----Original Message-----
From: Thomas Bellavia [mailto:TBellavia@V...]
Sent: Friday, February 22, 2002 2:14 PM
To: Access ASP
Subject: [access_asp] RE: rst.recordCount returns -1
Did you do a: if( rst.State == adStateOpen ) to see if it indeed did?
-----Original Message-----
From: Ping Li [mailto:pli@l...]
Sent: Friday, February 22, 2002 2:40 PM
To: Access ASP
Subject: [access_asp] rst.recordCount returns -1
I was trying to find the total number of the records. But it returns -1. Can
anybody tell me what's wrong with my codes?
Thanks a lot.
Ping
<%
dim rst, id
id = request.queryString("id")
set rst = Server.CreateObject("ADODB.Recordset")
sqlString = "exec sprInfo " & id
set rst = objConnection.execute (sqlString)
numOfRecords = rst.RecordCount
%>
Message #4 by "e n z o" <enzaux@g...> on Sat, 23 Feb 2002 04:05:46 +0800
|
|
Hi Ping,
I'm not quite sure on how to solve your problem but the problem on
that one is the cursor in recordset. I don't know how do they set it, I
don't remember the name but it has something to do with the cursor locatioin
(I hope I'm thinking right). I used a different way of getting the
recordset, I instead do it like this way:
Set rs = server.createobject("adodb.recordset")
rs.open "SELECT * FROM tblNames", ObjConn, adOpenstatic,
adLockOptimistic, adCmdText
With this I can get the correct rs.Recordcount. But if you try to use
the parameter adOpenForwardonly you would also get -1 recordcount. For more
information you can go http://www.adopenstatic.com this is great site of Ken
Schaefer. Check this out and you'll find the answer for sure. He's been
posting it many times long time ago. Try searching the archives of Wrox.
Enzo :)
----- Original Message -----
From: "Ping Li" <pli@l...>
To: "Access ASP" <access_asp@p...>
Sent: Saturday, February 23, 2002 3:39 AM
Subject: [access_asp] rst.recordCount returns -1
> I was trying to find the total number of the records. But it returns -1.
Can
> anybody tell me what's wrong with my codes?
> Thanks a lot.
> Ping
> <%
> dim rst, id
> id = request.queryString("id")
>
> set rst = Server.CreateObject("ADODB.Recordset")
> sqlString = "exec sprInfo " & id
> set rst = objConnection.execute (sqlString)
> numOfRecords = rst.RecordCount
> %>
>
$subst('Email.Unsub').
>
Message #5 by Ping Li <pli@l...> on Fri, 22 Feb 2002 15:37:13 -0600
|
|
Thanks, Enzo,
I understand your example by using rs.open to specify adOpenStatic. The
problem is that I don't know how to do that when I execute stored procedure
with passing parameter. I will look at the site you mentioned. Thanks again.
Ping
-----Original Message-----
From: e n z o [mailto:enzaux@g...]
Sent: Friday, February 22, 2002 2:06 PM
To: Access ASP
Subject: [access_asp] Re: rst.recordCount returns -1
Hi Ping,
I'm not quite sure on how to solve your problem but the problem on
that one is the cursor in recordset. I don't know how do they set it, I
don't remember the name but it has something to do with the cursor locatioin
(I hope I'm thinking right). I used a different way of getting the
recordset, I instead do it like this way:
Set rs = server.createobject("adodb.recordset")
rs.open "SELECT * FROM tblNames", ObjConn, adOpenstatic,
adLockOptimistic, adCmdText
With this I can get the correct rs.Recordcount. But if you try to use
the parameter adOpenForwardonly you would also get -1 recordcount. For more
information you can go http://www.adopenstatic.com this is great site of Ken
Schaefer. Check this out and you'll find the answer for sure. He's been
posting it many times long time ago. Try searching the archives of Wrox.
Enzo :)
----- Original Message -----
From: "Ping Li" <pli@l...>
To: "Access ASP" <access_asp@p...>
Sent: Saturday, February 23, 2002 3:39 AM
Subject: [access_asp] rst.recordCount returns -1
> I was trying to find the total number of the records. But it returns -1.
Can
> anybody tell me what's wrong with my codes?
> Thanks a lot.
> Ping
> <%
> dim rst, id
> id = request.queryString("id")
>
> set rst = Server.CreateObject("ADODB.Recordset")
> sqlString = "exec sprInfo " & id
> set rst = objConnection.execute (sqlString)
> numOfRecords = rst.RecordCount
> %>
>
$subst('Email.Unsub').
>
Message #6 by "Ken Schaefer" <ken@a...> on Sat, 23 Feb 2002 15:12:12 +1100
|
|
www.adopenstatic.com/faq/recordcounterror.asp
is the page that explains the error
www.adopenstatic.com/faq/recordcountalternatives.asp
are better ways to get the record count.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Ping Li" <pli@l...>
Subject: [access_asp] Re: rst.recordCount returns -1
: Thanks, Enzo,
: I understand your example by using rs.open to specify adOpenStatic. The
: problem is that I don't know how to do that when I execute stored
procedure
: with passing parameter. I will look at the site you mentioned. Thanks
again.
: Ping
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Message #7 by Ping Li <pli@l...> on Mon, 25 Feb 2002 09:10:01 -0600
|
|
Thanks to both Ken and Enzo. Your suggestions are really helpful. I am able
to get the proper recordcount by changing rst.CursorLocation to adUseClient.
But does it mean that I can't get proper recordcount if I use set rst
objConnection.execute storedProc to open the rst?
Thanks again.
Ping
-----Original Message-----
From: Ken Schaefer [mailto:ken@a...]
Sent: Friday, February 22, 2002 10:12 PM
To: Access ASP
Subject: [access_asp] Re: rst.recordCount returns -1
www.adopenstatic.com/faq/recordcounterror.asp
is the page that explains the error
www.adopenstatic.com/faq/recordcountalternatives.asp
are better ways to get the record count.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Ping Li" <pli@l...>
Subject: [access_asp] Re: rst.recordCount returns -1
: Thanks, Enzo,
: I understand your example by using rs.open to specify adOpenStatic. The
: problem is that I don't know how to do that when I execute stored
procedure
: with passing parameter. I will look at the site you mentioned. Thanks
again.
: Ping
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Message #8 by "Ken Schaefer" <ken@a...> on Tue, 26 Feb 2002 09:40:10 +1100
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Ping Li" <pli@l...>
Subject: [access_asp] Re: rst.recordCount returns -1
: Thanks to both Ken and Enzo. Your suggestions are really helpful. I am
able
: to get the proper recordcount by changing rst.CursorLocation to
adUseClient.
: But does it mean that I can't get proper recordcount if I use set rst
: objConnection.execute storedProc to open the rst?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
That's correct.
I suggest you look at use .getRows to handle these situations. Using a
VBScript array is *much* faster than using a heavy recordset object. As an
additional bonus, you get an recordcount by doing:
intRecordCount = UBound(arrResults, 2) + 1
Cheers
Ken
Message #9 by Ping Li <pli@l...> on Mon, 25 Feb 2002 17:20:02 -0600
|
|
Thanks for your explanation. Ken. I'll try what you said.
Have a nice evening.
Ping
-----Original Message-----
From: Ken Schaefer [mailto:ken@a...]
Sent: Monday, February 25, 2002 4:40 PM
To: Access ASP
Subject: [access_asp] Re: rst.recordCount returns -1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Ping Li" <pli@l...>
Subject: [access_asp] Re: rst.recordCount returns -1
: Thanks to both Ken and Enzo. Your suggestions are really helpful. I am
able
: to get the proper recordcount by changing rst.CursorLocation to
adUseClient.
: But does it mean that I can't get proper recordcount if I use set rst
: objConnection.execute storedProc to open the rst?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
That's correct.
I suggest you look at use .getRows to handle these situations. Using a
VBScript array is *much* faster than using a heavy recordset object. As an
additional bonus, you get an recordcount by doing:
intRecordCount = UBound(arrResults, 2) + 1
Cheers
Ken
|
|
 |