+ Reply to Thread
Results 1 to 3 of 3

After opening a recordset from an ADO connection I can no longer insert new records?

  1. #1
    Registered User
    Join Date
    07-10-2013
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    77

    After opening a recordset from an ADO connection I can no longer insert new records?

    I have a sub that connects to SQL, creates a couple of temp tables, and opens a recordset from one of the temp tables. After opening the recordset, it creates another temp table called #Temp5 and attempts to insert records. However, I'm getting an error message that the object name #Temp5 is not valid. It's strange because I don't get any error when creating it, but it's like creating the table never even happened. When I comment out the opening of the recordset earlier in the sub, the values are inserted into #Temp5 without a problem


    Does anyone know the logic behind this?

  2. #2
    Registered User
    Join Date
    07-10-2013
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    77

    Re: After opening a recordset from an ADO connection I can no longer insert new records?

    After looking into this a bit more it appears that I can't alter any part of the connection when the recordset is open, but that still doesn't explain why I'm not getting an error when trying to create the table in the first place

  3. #3
    Registered User
    Join Date
    07-10-2013
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    77

    Re: After opening a recordset from an ADO connection I can no longer insert new records?

    I tried a few more things and this is what I found:

    -If the Create table and insert values statements are all done in ONE execute command, there is no error regardless of if the recordset is open. If they are done in separate commands one after the other, there will be an error if the recordset is open but not if the recordset is closed

    -The temporary table IS being created when the recordset is open but still not recognized when trying to insert records. If I open the recordset, create the table, close the recordset, and try to create the table again, i will get an error saying the table already exists. However if I try to then insert values somehow it's not recognized

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Creating, Opening and Closing Connection and Recordset Objects
    By DGB48 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-28-2013, 04:36 PM
  2. CopyFromRecordset does return only 1000 records while recordset have 4000 records
    By KRUSHNAT in forum Access Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2012, 05:47 PM
  3. Excel sql, recordset & connection
    By Snoopy2003 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-05-2012, 05:32 PM
  4. [SOLVED] ADO Connection vs Recordset objects.
    By DaveO in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-12-2006, 09:45 AM
  5. Connection to AS400 and using a recordset
    By oz_saar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2005, 07:44 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1