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.CommandText = "SelecRecords:
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.