VB6 ADODB.Recordset RecordCount property always returns -1

前端 未结 12 1816
别跟我提以往
别跟我提以往 2020-12-11 15:43

I am trying to get some old VB6 code to work with SQL Server Compact.

I can connect, open the database and all seems well. I can run insert select commands which

12条回答
  •  臣服心动
    2020-12-11 16:26

    From memory with working with VB6/ADO a long time ago the .RecordCount field doesn't return meaningful data until you've moved to the end of the recordset.

    rs.MoveLast
    rs.MoveFirst
    Debug.Print rs.RecordCount
    

    Though with this you'll need to make sure you have the appropriate cursor type (i.e., not forward only).

    The only other solution I can think of is to do a separate SELECT COUNT(*) FROM myTestTable, etc but this has issues with the data changing between that call, and the one that actually returns the rows.

提交回复
热议问题