|
-
Nov 14th, 2004, 03:20 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Getting the Recordcount
Hey guys a lil help pls...
VB Code:
Dim objDB As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Command1_Click()
rs.Open "select * from card_Header", objDB.ConnectionString, , , adCmdText
Debug.Print rs.RecordCount
End Sub
Private Sub Form_Load()
Set objDB = New ADODB.Connection
Set rs = New ADODB.Recordset
objDB.Open "provider=microsoft.jet.oledb.4.0;data source=D:\Documents and Settings\Ruikeish\My Documents\mrserver.mdb"
End Sub
Why does Debug.print rs.RecordCount prints -1? instead of printing the no. of records of the table.
Thanks a lot...
Last edited by charmedcharmer; Nov 15th, 2004 at 02:01 AM.
C++ Programming is overwhelming.
Dont let it overwhelm you or you'll fall into the oblivion of its perfection
-
Nov 14th, 2004, 03:34 AM
#2
I knew that I've seen this before.
The RecordCount property will always be -1 when using a Server Side cursor. Change the CursorLocation property to adUseClient.
I just searched for rs.recordcount...
-
Nov 14th, 2004, 01:22 PM
#3
Not exactly true. To get a recordcount you also need to specify a
cursor type that supports the recordcount property. The Keyset
cursor or Static cursor types support recordcount property and
use a serverside cursor location.
Also, it depends on the provider that your using.
Third, when you dont specify the cursor type and lock type, the
defaults are used which are adFordwardOnly and adLockReadOnly.
Maybe try this, depending on your provider.
VB Code:
rs.Open "select * from card_Header", objDB.ConnectionString, adOpenKeyset, adLockOptimistic, adCmdText
Best bet is to search MSDN for "Recordcount" because there
are allot of situations that can affect the support of the recordcount
property. For example if your application deletes records in a
dynaset-type Recordset object, the value of the RecordCount
property decreases. However, records deleted by other users
aren't reflected by the RecordCount property until the current
record is positioned to a deleted record.
Also, when you work with linked TableDef objects, the
RecordCount property setting is always – 1.
This is why I say to read the help file for your particular use.
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Nov 14th, 2004, 08:21 PM
#4
I was trying to point him in the right direction. I quoted a resolved thread, so I thought that I had it.
-
Nov 14th, 2004, 09:11 PM
#5
Thread Starter
Addicted Member
are there any resolved threads already? well thanks for the help.. ur very helpful.. i'll try both your answers a lil later... ill look for that resolved thread if there is any. kindly post the resolved thread if you find it first.. thanks a lot! i mean thank you thank you thank you thank you....
C++ Programming is overwhelming.
Dont let it overwhelm you or you'll fall into the oblivion of its perfection
-
Nov 14th, 2004, 10:13 PM
#6
I think that it was before the use of the checkmark. It ended in "Thank You" or something to that effect. If you search for the quote, then you should find the post.
-
Nov 14th, 2004, 10:31 PM
#7
I quoted brucevde:
here
I guess that I assumed that it was resolved. Sorry.
-
Nov 15th, 2004, 02:00 AM
#8
Thread Starter
Addicted Member
thanks... just tried your suggestions... it work as i wanted it.. thanks alot... i mean, thank you very much!
C++ Programming is overwhelming.
Dont let it overwhelm you or you'll fall into the oblivion of its perfection
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|