Here is one thing I found, assuming I understand and it applies.
Jim
The fastest method is to use Indexed Sequential Access Method - ISAM. This allows for directly transfering data from your connected ADO record source to a second dynamically connected datasource. I figured out how to do this this week and it is the only way to fly! Do yourself a favor any try this, you will be glad that you did!
1. Use an ADODB.Connection to connect to ANY ADO DB using the standard connection strings (
www.connectionstrings.com).
2. Once connected, in the SQL query instead of entering a destination table name use an ISAM name to interact with a seperate DB.
3. Note that the Excel drivers work for BOTH 2003 and 2007 even though the version says 8.0 (it is not 12.0). This threw me for a bit as 8.0 is how to specify 2003 in a connection string.
4. Using this method I am able to transfer data between any two data sources (since the initial connection can by to any datasource) using a single SQL statement including CSV, Excel 2003/2007, Access 2003/2007, SQL Server. I think I have even seen a DB2 example, so others are be possible.
Here is the syntax:
SELECT * INTO <Put ISAM Name Here> FROM <normal query syntax to connected DB and table>
INSERT * INTO <Put ISAM Name Here> FROM <normal query syntax to connected DB and table>
or
SELECT * INTO <normal query syntax to connected DB and table> FROM <Put ISAM Name Here>
INSERT * INTO <normal query syntax to connected DB and table> FROM <Put ISAM Name Here>
...other options are possible, the point is just to replace the table name with the ISAM Name in the query.
ISAM Names:
CSV & TXT
[Text;Database=C:\_Path\;HDR=Yes].[File.csv]
[Text;Database=C:\_Path\;HDR=Yes].[File.txt]
Access 2003 & 2007
[MS Access;Database=C:\Path\File.mdb].[AccessTableName]
[MS Access;Database=C:\Path\File.accdb].[AccessTableName]
Excel 2003 & Excel 2007
[Excel 8.0;HDR=Yes;IMEX=1;MaxScanRows=16;Database=C:\Path\File.xls].[Table$]
[Excel 8.0;HDR=Yes;IMEX=1;MaxScanRows=16;Database=C:\Path\File.xlsx].[Table$]
[Excel 8.0;HDR=Yes;IMEX=1;MaxScanRows=16;Database=C:\Path\File.xlsm].[Table$]
[Excel 8.0;HDR=Yes;IMEX=1;MaxScanRows=16;Database=C:\Path\File.xlsb].[Table$]
SQL Server
[ODBC;Driver=SQL Server;SERVER=<Server Name>;DATABASE=<Database Name>;UID=<UserName>;PWD=<password>;].
Here are some links: http://support.microsoft.com/kb/321686 http://support.microsoft.com/kb/200427
Additionally, if you would like to create a file based CSV, Excel 2003/2007, Access 2003/2007 database via the ADO connection, that can be done using the ADOX object.
Set oADOXDatabase = New ADOX.Catalog
oADOXDatabase.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & <path to file>)
The combination of these concepts allows for the creation and population of a DB file using ADO very quickly.
I have working code for this, so I can tell you that it works great if you feel the need...the need for speed!
Greg Harward
Bob Barker wrote: |