|
-
Feb 25th, 2007, 06:39 AM
#1
Thread Starter
New Member
[RESOLVED] Cannot use 'RecordCount' property...
Hi all,
I am using VB6 and i just cannot seem to get the RecordCount property of the recordset correctly. For example, when I tried using this property on form_load(), it always gives me a value of -1 even though the recordset contains 5 or 6 objects.
I need this property for two uses. Firstly to count and display the number of matching records found when the 'Search Results' form is loaded and secondly, to determine the no. of records left in the recordset when a record is deleted and if no record is left, then to close the form using form.hide method.
Can anyone please help me with this? Any help will be greatly appreciated. Thanks in advance for any help.
-
Feb 25th, 2007, 08:21 AM
#2
New Member
Re: Cannot use 'RecordCount' property...
what style database?
what is your curser location set to?
-
Feb 25th, 2007, 10:38 AM
#3
Re: Cannot use 'RecordCount' property...
I suspect CundiRob has got the issue - cursor location. The recordcount is -1 if the actual amount of records is currently unknown, which is the case for server-side cursors.
However, based on what you said you have no need whatsoever for the recordcount anyway - simply using the .BOF and .EOF properties would work for you, which would be quicker, simpler code, and use less memory. eg:
VB Code:
'displaying records
rs.Open ...
Do While Not rs.EOF
'use the recordset values here
rs.MoveNext
Loop
'checking if there are records remaining:
If rs.BOF and rs.EOF Then
MsgBox "no records remaining in the recordset!"
End If
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
|