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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RecordCount = -1 (ADO; SQL SERVER) 1

Status
Not open for further replies.

crisedefoie

Programmer
Feb 19, 2003
39
0
0
CA
Hello!

I have a reccurent problem :

I have a program in VB6 using SQL Server Database. When I try to open a recordset and to know the recordcount, it always return -1!!!!

I saw in other topics many advices about cursor type etc..
but ... it doesn't work neither.

There is a piece of my code :

With rcstMesurage
.Open "(SELECT BillID, BillDate FROM Bills1) UNION
(SELECT BillID, BillDate FROM Bills2)",
MyConnection, adOpenKeyset, adLockOptimistic
If Not .EOF Then
.MoveLast
ldBillCount = .RecordCount
.MoveFirst
end if

'initializing progress bar (....)

while not .EOF
(.....)
.movenext
wend

.close
End with

The recordcount always return -1 but .EOF = False !!!
Is there someone who knows how to resolve this, please?

I tried many things but it didn't work

Thanks



 
You should really try to avoid using the recordcount property.

Make sure that the cursor location of the connection and the recordset are set to adcursorclient, not server.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
I second Frederico's recommendation -- you should not rely on the RecordCount property.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top