Link to home
Start Free TrialLog in
Avatar of ChenChen
ChenChenFlag for Afghanistan

asked on

ADO Execute command

I want to use an ADO "execute" command to add  new records into a talbe,something like this:

'presume I've already got a connection called cn
dim rs as Recordset
set rs=cn.Execute("insert into "Table1" (column1,column2) values ('something','and more')")

This command works fine for adding record to the table. Now, the problem is that I also want to use the rs which I expect to be a valid recordset returned by the command. But I always get a error message saying that "object is closed.".

Would anyone know what the problem is?
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

because the INSERT statement is not returning a recordset.

a recordset is returned when you do a SELECT * FROM Table1.
Avatar of ChenChen

ASKER

Are you sure? emoreau, I thought "Execute" always returned a Recordset object reference if successful.
I am 110 % sure of this.

INSERT, UPDATE and DELETE statements can only return the number of affected records. To retreive this value, pass a long variable as the second parameter of the EXECUTE method.
sorry,CheChen,but emoreau is 1000% correct--- Only a SELECT query will return a recordset.

Arthur Wood
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial