ChenChen
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?
'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?
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.
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
Arthur Wood
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
a recordset is returned when you do a SELECT * FROM Table1.