473,219 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,219 software developers and data experts.

ADODB.RecordSet, RecordCount always return -1

Hi,

I have an ADODB.RecordSet that RecordCount alway return -1 and this
RecordSet is plenty of record!

R.RecordSet = -1
R.eof = False
R.BOF = False

Is the cursor is lost somewhere?

How can I do to get the number of record in the result set?

Thank you in advance
serge
Jul 19 '05 #1
7 41819
Serge Myrand wrote:
Hi,

I have an ADODB.RecordSet that RecordCount alway return -1 and this
RecordSet is plenty of record!

Your answer will be found here:
http://www.aspfaq.com/show.asp?id=2193

HTH,
Bob Barrows
--
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.
Jul 19 '05 #2
Great, thank you
"Bob Barrows [MVP]" wrote:
Serge Myrand wrote:
Hi,

I have an ADODB.RecordSet that RecordCount alway return -1 and this
RecordSet is plenty of record!

Your answer will be found here:
http://www.aspfaq.com/show.asp?id=2193

HTH,
Bob Barrows
--
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.


Jul 19 '05 #3
I am sorry for posting in the wrong forum, it's bad when searching
answers..

Serge Myrand wrote:
Hi,

I have an ADODB.RecordSet that RecordCount alway return -1 and this
RecordSet is plenty of record!

R.RecordSet = -1
R.eof = False
R.BOF = False

Is the cursor is lost somewhere?

How can I do to get the number of record in the result set?

Thank you in advance
serge


Jul 19 '05 #4
IPT
I went to the web, and still unable to get it work.

My codes:

sSQL = "SELECT * FROM myTable"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sSQL, myConn, 1, 3
recCount = rs.recordcount
rs.Close
Set rs = Nothing
response.write recCount

It returns -1.

Help!
Serge Myrand wrote:
Hi,

I have an ADODB.RecordSet that RecordCount alway return -1 and this
RecordSet is plenty of record!

Your answer will be found here:
http://www.aspfaq.com/show.asp?id=2193

HTH,
Bob Barrows
--
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.

Jul 19 '05 #5
Are you Serge?

What is your backend database?

IPT wrote:
I went to the web, and still unable to get it work.
Why bother? If you read the article I linked to, you will find a more
efficient method (using GetRows) for getting the record count than using an
expensive cursor for your recordset.

My codes:

sSQL = "SELECT * FROM myTable"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sSQL, myConn, 1, 3
You do not need an ultra-expensive keyset cursor (although it should work).
All you need is a static cursor. The locktype does not matter.
rs.Open sSQL, myConn, 3, 3, 1
recCount = rs.recordcount
rs.Close
Set rs = Nothing
response.write recCount

Does this reflect your actual purpose? You are opening a recordset for the
sole purpose of getting the record count? That's crazy! Don't pull all the
records from your table across the wire simply to count them.

sSQL = "SELECT count(*) FROM myTable"
set rs = conn.execute(sSQL,,1)
recCount = rs(0)
rs.Close
Set rs = Nothing
conn.Close
Set conn= Nothing
response.write recCount
It returns -1.

Help!


It should not return -1 with a keyset cursor, unless the provider you are
using for your connection does not support bookmarks. That is why I asked
what database you are using, and why I am now asking you to show us your
connection string (with any password information censored of course).

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #6
IPT
I'm not Serge.

I use mySQL 4.0, does it support bookmark (.AbsolutePage)?

I used to use Ms Access, and has many functions. Since migrate to mySQL, I
need to modify many codes pertaning to SQL systax. I can't use anymore saved
queries, nested select, etc. Even the 'getdate()' has changed to 'Now()'.

Any free database server you may suggest?
Jul 19 '05 #7
IPT wrote:
I'm not Serge.

I use mySQL 4.0, does it support bookmark (.AbsolutePage)?
I have no idea. One way to find out is to use the Supports method.
http://msdn.microsoft.com/library/en...thsupports.asp

http://msdn.microsoft.com/library/en...ecordcount.asp


I used to use Ms Access, and has many functions. Since migrate to
mySQL, I need to modify many codes pertaning to SQL systax. I can't
use anymore saved queries, nested select, etc. Even the 'getdate()'
has changed to 'Now()'.

Any free database server you may suggest?


Why not MSDE?

Bob Barrows
--
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.
Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: elcc1958 | last post by:
I need to support a VB6 application that will be receiving disconnected ADODB.Recordset from out DotNet solution. Our dotnet solution deals with System.Data.DataTable. I need to populate a...
0
by: Dot Netizen | last post by:
I am having trouble passing an ADODB.Recordset from a VB6 application to a VB.Net class library using COM Interop. I am running this on XP SP2 with the .Net Framework 1.1 and MDAC 2.8 SP1. I've...
4
by: jl | last post by:
Hello, I am trying to determine if a recordset is empty or not, and if it is empty print out a message saying no records found. I thought I could use rs.RecordCount but it always seems to return...
5
by: Simone | last post by:
Hello I hope you guys can help me. I am very new to ADO... I am creating a ADODB connection in a module and trying to access it from a command button in a form. Function fxEIDAssgn(plngEID As...
0
by: CFW | last post by:
I thought this was going to be easy but I'm missing something . . . I need to open an ADODB recordset using the recordset source for a list box on my for. When my form opens, the list box ADODB...
6
by: Andy Barber | last post by:
Hi, I'm trying to write an app that reads data from a table into a string variable for later use in my program. Below is a snippet of the code I'm using, which compiles ok, but at runtime I get...
3
by: pooja1982 | last post by:
Hi, I m getting this message after executing the following code <% CALL OPENDATACON DIM RS SET RS=SERVER.CreateObject ("ADODB.RECORDSET") s="select * from dbpassenger order by ref_no" CALL...
3
by: mark_aok | last post by:
Hi all, All I am trying to do is open a table, edit it, and then close it. But I am having the strangest error. Here is my code Dim i as integer Dim rs as adodb.recordset Set rs = new...
6
by: Oko | last post by:
I'm currently developing an MS Access Data Project (.adp) in MS Access 2002. One of the reports within the DB uses data that is Dynamic and cannot be stored on the SQL Server. To resolve this, I...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.