Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: ADO
Expertise: Beginner
Aug 8, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

RecordCount Property-ADO

How do I get the rowseffected from the execute method of an ADO command object? The code I've written is:

Dim Cn as New ADODB.Connection
Dim Cmd as New ADODB.Command
Dim Recordset as New ADODB.Recordset
Dim lintRecEffected As Integer

Cn.Open "some connection string"

Cmd.ActiveConnection =Cn
Cmd.CommandText = "SelecRecords:        
Set Rs=lcmd.ExecutelintRecEffected)

msgbox lintreceffected

This shows -1 even though the record is inserted. By the way, my backend is db2.

The most important things to remember when working with ADO recordsets are the CursorType, CursorLocation, and LockType properties. In your code, you left these properties as the default settings:

CursorType = ForwardOnly
LockType = ReadOnly
CursorLocation = Server

The ForwardOnly cursor does not retrieve all of the records until they are need. It fetches them each time you call one of the Move methods. Therefore, ADO has no idea how many records will be returned from the recordset and returns a -1 for the recordcount. You will need to use one of the other CursorTypes in order to use the RecordCount property.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date