Recordcount = -1 problem

xiaoxiao2021-03-06  19

I often have a friend asking me, why clear the database has records, but recordcount = -1, see what is caused by

Usually people use two methods to perform SQL statements:

SET RS = Conn.execute (SQLSTR)

with

SET RS = Server.createObject ("AdoDb.Recordset")

RS.Open Sqlstr, Conn, Cursortype, LockType

(Recordset object method, please see here)

Since the default recordset is a server cursor,

Rs.cursorlocation = aduseserver

So returning rs.recordcount = -1,

The server cursor should be changed to the client game.

Rs.cursorlocation = aduseclient

RS.Open Sqlstr, Conn, Cursortype, LockType

Rs.cursortype

Cursor type RecordCount property

---------------------------------------------

Forwardonly 0 (default) Returns -1

KeySet 1 correct record number

Dynamic 2 -1 or incorrect record number, according to the data source

STATIC 3 correct record number

So rs.cursorlocation = 3

This property is supported by the RecordSet.support ("Property Name").

转载请注明原文地址:https://www.9cbs.com/read-52836.html

New Post(0)