Re: how to get recordcount from command.execute -- select * from t




"Rich" <Rich@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:994C986B-26FE-4218-86DB-BA1F94E81949@xxxxxxxxxxxxxxxx
Thank you very much for your reply. Very helpful. What I was missing was

cmd.ActiveConnection.CursorLocation = adUseClient.

Now I can get my RecordCount

There are times when a client cursor will be impractical, such as when the
query returns a large number of rows.

In those cases you'll need to make second query to get the row count:
SELECT COUNT(*) AS RecCount FROM Tbl1, which will return one row with one
field (containg the count, needless to say.)


-Mark




"Orimslala" wrote:

The ADO RecordCount property indicatest the number of records in a
recordset object, so that is the way to do it.

DIM intNumber as INTEGER
Dim RS As ADODB.Recordset

'
'
intNumber = RS.RecordCount

Also, make sure the CursorLocation property of your connection object
is set to adUseClient

Orims

Rich wrote:
Hello,

Dim cmd As New ADODB.Command, RS As New ADODB.Recordset
cmd.ActiveConnection = "...."
cmd.CommandType = adCmdText
cmd.CommandText = "Select * From tbl1"
Set RS = cmd.Execute

Is there a way to return the count of records returned? RS.RecordCount
returns a "-1". I tried RS.MoveLast and got an error "no forward
fetching".


I also tried with connection object - same thing

Set RS = conn.Excecute(strSql, recCount)

Any suggestions appreciated.

Thanks,
Rich




.



Relevant Pages