number of records in adodb.recordset

S

Sunny

Hi,

I am transfering data to spreadsheet and I need number of rows generated in
spreadsheet.

This is my code

Dim rs AS New ADODB.Recordset
Dim adoCommand AS ADODB.Command
....
....
....
set rs = adoCommand.Execute
xlWS.Cells(1,1).CopyFromRecordset rs - transfers about 5000 lines

n = rs.recordcont - which gives me -1 all time and

Is there any oter way to find # of rows transfered?

Thanks.
 
D

Dorian

From ADO Help:
Execute Method (ADO Connection)
Executes the specified query, SQL statement, stored procedure, or
provider-specific text.

Syntax
For a non–row-returning command string:

connection.Execute CommandText, RecordsAffected, Options
For a row-returning command string:

Set recordset = connection.Execute (CommandText, RecordsAffected, Options)
Return Value
Returns a Recordset object reference.

Parameters
CommandText
A String value that contains the SQL statement, stored procedure, a URL, or
provider-specific text to execute. Optionally, table names can be used but
only if the provider is SQL aware. For example if a table name of "Customers"
is used, ADO will automatically prepend the standard SQL Select syntax to
form and pass "SELECT * FROM Customers" as a T-SQL statement to the provider.
RecordsAffected
Optional. A Long variable to which the provider returns the number of
records that the operation affected.
Options
Optional. A Long value that indicates how the provider should evaluate the
CommandText argument. Can be a bitmask of one or more CommandTypeEnum or
ExecuteOptionEnum values.
Note Use the ExecuteOptionEnum value adExecuteNoRecords to improve
performance by minimizing internal processing.
Do not use the CommandTypeEnum values of adCmdFile or adCmdTableDirect with
Execute. These values can only be used as options with the Open and Requery
methods of a Recordset.

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top