VB and VBA Users Source Code: Tackle message Recordcount = -1 when using ADO
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Tackle message Recordcount = -1 when using ADO
By:
Soundar
Email (spam proof):
Email the originator of this post
Date:
Thursday, October 04, 2001
Hits:
748
Category:
Database/SQL/ADO
Article:
Hello People using ADO to retreive records from a database often donot get the correct record count...This is because the cursor type of the database they use by default would be a forward only cursor.... Following is a workaround to tackle this problem You need to Change your cursor type at the time of specifying your recordset A sample code is given below Set condb = application.CreateObject("ADODB.Connection") condb.Open "eazy", "CBSI_EAZY", "CBSI_EAZY" Set rs = application.CreateObject("ADODB.Recordset") rs.CursorLocation = 3 After running this connection code...if you try to retreive the record count through the statement rs.recordcount, you will get the exact count for the DB Hope this helps Thanks Soundar
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder