Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADODB RecordSet RecordCount Question
Message
 
 
To
24/12/1999 15:40:19
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00308445
Message ID:
00308447
Views:
25
An answer from just up the road on Route 30 - I live in Paoli....

How the RecordCount Property behaves is based on the type of cursor you are creating. Based on your code, you are creating a static cursor with batch optimistic locking.

Based on the code you have posted, the RecordCount Property should work. A few things to verify:

1. What version of ADO do you have? You can find this by running the following code:

? oConn.Version

At a minimum, you want to be running Version 2.0 or 2.1. Version 2.5 will be shipping with Windows 2000. If you are running Version 1.5, it is best you upgrade to 2.1 ASAP.

Just to remove any variables, try this code:

Public oConn,ors
oConn=CREATEOBJECT("ADODB.Connection")
WITH oConn
.Provider = "SQLOLEDB.1"
.ConnectionString = "User ID=sa;Initial Catalog = Pubs;Data Source= SCM_TWO2"
.Open
ENDWITH
lcselectstr = "Select * From Authors"
oRs=CREATEOBJECT("ADODB.RecordSet")
oRs.Open(lcselectstr,oConn,3,4)
?oRs.RecordCount

I get 23 for the Recordcount.

Based on what you are posting, you should be getting the correct Recordcount.


>I am using the following in VFP6 to pull records from a SQL Server 7 database.
>
>oConn=CREATEOBJECT("ADODB.Connection")
>WITH oConn
> .Provider = "SQLOLEDB.1"
> .ConnectionString = " Persist Security Info = False;User ID = sa;Initial Catalog = Portfolio;Data Source = SCM_TWO2"
> .Open
>ENDWITH
>
>lcselectstr = A very long SQL Statement
>oRs=CREATEOBJECT("ADODB.RecordSet")
>oRs.Open(lcselectstr,oConn,3,4)
>?oRs.RecordCount
>
>The data comes over just the way I want it but the RecordCount Property of the RecordSet Object returns a value of -1.
>Any ideas why this occurs?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform