Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Help Me Recordcout Property return-1

Status
Not open for further replies.

nandagopal2000

Programmer
Mar 19, 2002
6
0
0
IN

Hai Friends.

I Connect Oracle Database by using Microsoft ODBC for Oracle driver.

U use the Following Code

Dim con as new adodb.connection
dim rs as new adodb.recordset

con.open DSNName,UserName,Pwd

rs.open "select * from emp", con, adOpenDynamic, adLockOptimistic

Msgbox rs.recordcount

It Return -1 but emp table have 150 records
So i replace the cursor type adOpenDynamic to adOpenStatic
It Return 150 but Other User changes not reflected in the recordset

So,Please Help me ASAP

Nandagopal.R
 
Correction: The reason .recordcount returns -1, is that dynamic recordsets does not support the .recordcount property. In order to use .recordcount your must use 'Static' or 'keyset' cursortype.
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Sunaj is correct - you can't always trust the RecordCount property.

Either change the recordset type, or run a separate query:
Code:
select count(*) from emp

Chip H.
 
When you get strange responses, or no responses (like -1 for recordcount), you can use the recordset.supports property to ask it what you can and cannot do.

If you really do need to opendynamic, especially with a tiny recordset like this, you can just start at the beginning and count the rows until rs.eof.

As to why your count is wrong, could it be that you are not doing the rs.update method before you look at recordcount? Or using a transaction and not doing a commit?

I personally like the idea of select count(*).

So many opportunities.

Good luck,
Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top