Monday, February 20, 2012

Recordcount Issue

This is weird. I have (identical) copies of sql server running on two seperate machines. I have a vb app that accesses the data. It runs with both dbs but I have the following function that I call to show the record count in a particular display:

Code:------------------------

Dim rs As Recordset

'determines number of records in a sql statement
Set rs = New ADODB.Recordset
rs.Open sql, conn, adOpenStatic, adLockOptimistic
RecordCount = rs.RecordCount
rs.Close
Set rs = Nothing

------------------------With one db it works just fine but with the other it returns a value of -1 even though the data is displayed just fine. Any ideas?You need to make sure that you have a client side sursor for this to work.

I always work with disconnected recorsets so it's not an issue.|||I'm not a VB expert, but I think you need to use rs.movelast in order to get an accurate count.

blindman

No comments:

Post a Comment