|
-
Apr 7th, 2006, 10:29 PM
#1
Thread Starter
Addicted Member
Closing Recordsets
Hi I just want to ask why I receive an error from
VB Code:
rs.open "Insert Into Table (a,b,c) values ('a','b','c')",con
rs.close:set rs=nothing
but not from
VB Code:
rs.open "Select * from table",con
rs.addnew
rs.update
rs.close:set rs=nothing
The error is "Function is not allowed when object is closed" ..... thanks in advance
-
Apr 7th, 2006, 10:32 PM
#2
Frenzied Member
Re: Closing Recordsets
the error happens in the rs.close code right
it is because the record is not actually opened. there is no such query as select into statement
maybe what you want is to insert a record to a database.
you should use insert into statement if thats the case
On error goto Trap
Trap:
in case of emergency, drop the case...
****************************************
If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option. if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar
-
Apr 7th, 2006, 10:34 PM
#3
Re: Closing Recordsets
In the first example, the recordset wasn't ever opened.... no data was returned.
FYI: That's not a good way to run those kind of SQL Statements (the kind that don't actualy return data are called Action Queries - Insert, Delete, Update) but instead you should use the Command object and the Execute method. There's a couple of ADO tutorials in my sig, they go over this kind of stuff.
-tg
-
Apr 7th, 2006, 10:48 PM
#4
Thread Starter
Addicted Member
-
Apr 8th, 2006, 09:42 AM
#5
Re: Closing Recordsets
?? Really? Which one(s) .... I just checked them and they worked for me....
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|