title: If i create a disconnected ADO recordset from scratch in VBA how do i set the base table information for UpdateBatch?
body: <p>I have been using disconnected recordsets for a few weeks now, typically retrieving data from SQL Server, disconnecting the rs and filtering/formatting in VBA. Now i'm trying to do the reverse and create a new ADO recordset from scratch, and then connect it to my database and use UpdateBatch to insert the recordset into the database without using a loop. I have a fully populated recordset at this point, hooked it back up to my connection string, and try UpdateBatch. Understandably, it has no information at this point about what table I'm trying to update (only Data Source and Initial Catalog via the connection string). Is there a recordset property that I use to provide the table in question? Additionally, the table I'm trying to import into has a GUID field (first field) that I have left blank on purpose in my disconnected recordset assuming that upon import, SQL Server would assign this GUID/primary key automatically.</p>
  
  <p>The specific error I'm getting after "rs.UpdateBatch" is 
  Run-time error '-2147467259 (80004005)'"
  Insufficient base table information for updating or refreshing.</p>
  
  <p>I know I could use a loop and a SQL command "INSERT INTO ...". I'd like to use a recordset object though since those provide much more functionality as a container for data. One thing I haven't tried is to first retrieve a recordset from the table in question, then clear it and re-populate it with the new data so that the recordset itself retains all of the original database and table properties. If that's the only/best approach I can try that route too. I just wanted to see if it was possible to create an ADO recordset, populate it, and then insert it into a matching table of my choice. </p>
  
  <pre><code>dim rs as ADODB.Recordset
  set rs = New ADODB.Recordset
  
  With rs.Fields
      .append "alias", adVarChar, 255
      .append "textA", adVarChar, 255
      .append ......
  End With
  
  rs.Open
  rs.AddNew Array(0, 1, 2, ..., n), Array(val0, val1, val2, ..., valn)
  rs.Update
  
  call importRS(rs)
  
  rs.close
  set rs = nothing
  </code></pre>
  
  <hr>
  
  <p>After rs.update above some recordsets may need to go to a database, other recordset objects are just used to expedite filtering and sorting so I just use them as a convenient container and they'd never go to importRS()</p>
  
  <p>However, IF I need to send the disconnected recordset to a database, i'd like to just pass the recordset object to another function that serves the purpose of opening the connection, sending the update, and closing the connection. The code below would serve that purpose which is why i'd like to wait to establish a connection until this point, right at the end after my rs is populated.</p>
  
  <pre><code>sub importRS(byref rs as ADODB.Recordset)
  dim cn as ADODB.Connection
  set cn = New ADODB.Connection
  cn.ConnectionString = strConnection 'my connection string variable'
  cn.Open
  
  rs.ActiveConnection = cn
  rs.UpdateBatch '-------error message appears on this line
  
  cn.close
  set cn = nothing
  </code></pre>