Results 1 to 5 of 5

Thread: Closing Recordsets

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2004
    Location
    Philippines
    Posts
    149

    Closing Recordsets

    Hi I just want to ask why I receive an error from

    VB Code:
    1. rs.open "Insert Into Table (a,b,c) values ('a','b','c')",con
    2. rs.close:set rs=nothing

    but not from

    VB Code:
    1. rs.open "Select * from table",con
    2. rs.addnew
    3. rs.update
    4. rs.close:set rs=nothing

    The error is "Function is not allowed when object is closed" ..... thanks in advance

  2. #2
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    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

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,953

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2004
    Location
    Philippines
    Posts
    149

    Re: Closing Recordsets

    d3gerald: I mistyped
    techgnome: thank you for the information. I will read the tutorials immediately. I did not realize that I was doing it the wrong way

    **Edit

    Some of the links in your sig is broken
    Last edited by Zelot; Apr 7th, 2006 at 11:27 PM.

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,953

    Re: Closing Recordsets

    ?? Really? Which one(s) .... I just checked them and they worked for me....

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width