RecordSet.RecordCount=1

RecordSet.RecordCount=1

Anonymous
Not applicable
177 Views
2 Replies
Message 1 of 3

RecordSet.RecordCount=1

Anonymous
Not applicable
Dear All,

My program code as below:

.......

   Dim db As dATABASE
   Dim
rs As Recordset
   Dim I As Integer, nRecNo As Integer, nNo As
Integer

   Set db =
DBEngine.Workspaces(0).OpenDatabase(DataBaseFile, False)
   Set rs
= db.OpenRecordset("Select * From TABLENAME") 

   If rs.EOF
Then    

      MsgBox "No
data"
   Else
      nRecNo =
rs.RecordCount
      MsgBox
Str(nRecNo)
    End If

 

I have 14 records in table, but the messagebox
shows 1, Why?

 

Thanks in advance!

 

 

Arno Weng

 
0 Likes
178 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
With ADO and DAO especially you have to
issue:

 

rs.MoveLast

 

to force the database engine to actually go through
the records and count them (which could waste time if you just want to start
looking at the data). I think some types of recordsets (possibly the snapshot
type) will count them all when the recordset returns. Then there are other types
of recordsets (like forward only types) that won't let you even use rs.MoveLast
since it can only move one record at a time.

 

I've seen a lot of posts with people using Oracle,
so it gets even more troublesome in that case... the more knowledgable guys in
the group will have to help with that stuff!

 

Good luck!

 
0 Likes
Message 3 of 3

Anonymous
Not applicable
Thanks!

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

With ADO and DAO especially you have to
issue:

 

rs.MoveLast

 

to force the database engine to actually go
through the records and count them (which could waste time if you just want to
start looking at the data). I think some types of recordsets (possibly the
snapshot type) will count them all when the recordset returns. Then there are
other types of recordsets (like forward only types) that won't let you even
use rs.MoveLast since it can only move one record at a time.

 

I've seen a lot of posts with people using
Oracle, so it gets even more troublesome in that case... the more knowledgable
guys in the group will have to help with that stuff!

 

Good luck!

 
0 Likes