View Full Version : [SOLVED:] Using ADODB to
JKwan
02-18-2016, 04:06 PM
I am wondering if I can use ADODB to run a Access command. The command that I liked to run is DoCmd.TransferText. The main reason is that my users do not have Access. I need to load a huge csv file into a table. The DoCmd is really fast, but if I use ADODB, I need to loop thru the file and Insert into the table, this takes about 15 minutes to complete.
No it can't.
Access runtime is a free download.
You can link a text file as a table and use a query.
JKwan
02-19-2016, 05:01 PM
That is what I thought, all that I found on the web is using an instance of Access....
The Access runtime is no good. The PC is locked down, therefore, I need the admin password in order to install it :-(
Describing the process could help.
JKwan
02-19-2016, 07:19 PM
Basically, I wanted to run DoCmd.TransferText command without creating an instance of Access. How would one does it?
I thought you were more interested in a faster data transfer between two systems, in which case some information about the process would have been useful.
But, yeah, if it's just about docmd which is an Access function, I already answered that.
JKwan
02-21-2016, 09:16 PM
Yes, basically I am looking at a faster way to load my input file into Access. As I describe with my original post, I am looking for a way to import a csv file into Access, currently I am using SQL insert with ADODB, which is really slow. The file contains really basic info, like MeterNumber, Date, Temperature, Pressure. The biggest gotcha is that the file contains like a million rows. To me, the only process is to import the csv file, I hope that you may have other idea which can speed it up. Thanks again for trying to help.
Editing records directly is very slow compared to querys.
You need to somehow open the text file in a format that you can generate a query from and the easiest way to do that (that I can think of) is to link the text file as a table as I said above.
Because the file is linked you can replace it whenever you get a new file (as long as the new file has the same filename and format.)
So, say the users are using live.accdb.
Maybe you don't want to change/redistribute that db, so you could create the link in a new db, e.g. 'txtlnk.accdb'.
Then you execute SQL to transfer the data between the two. e.g.
<html><head><script language=vbscript>
ACC2007 = "provider=microsoft.ace.oledb.12.0;data source=%path%;"
txtlnkPath = "X:\db\txtlnk.accdb"
LiveDBPath = "X:\db\live.accdb"
Function GetDBStr(db,path)
GetDBStr = Replace(db, "%path%", path)
End Function
sub main()
Dim con 'As New ADODB.Connection
set con = createobject("ADODB.Connection")
con.open GetDBStr(ACC2007,txtlnkPath)
con.execute "select * into [" & LiveDBPath & "].NewTable from [csvlink]"
run.innerhtml="done"
end sub
</script></head><body>
<div id='run'><button onclick='main'>run</button></div>
</body><html>
JKwan
02-22-2016, 10:36 AM
jonh, thanks for the idea of using Link Text file. I am able to make use of your idea and make my solution work really fast, A BIG THANK YOU.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.