Exporting Access Tables Programmatically
alright, after a few hours of searching and reading all over the net, I have broken down and decided to ask for help. I am working to automate many of the more medial and repetitive tasks as work, and stumbled upon AutoIt, I love the tool. anyway, Today's task is the export of a slew of tables and queries from Access 2007 in a few different formats. mostly CSVs some Tab delimited, and a couple of dBase DBFs and DBTs. now none of this is all that difficult and in fact the person who previously held my position created about a hundred Macros in the mdb that export the tables. seems to me that he fell well short of hastening the process as you still have to run each macro. I am looking to create an autoit script that will export the correct tables in the correct format to the correct place with the correct name. doesn't seem like it should be that difficult.
so thus far I have been imagining using ADO to tell Access to export which table in which format and where. but I cannot seem to find the necessary commands needed to do that. I also figured that perhaps, at least with the text based formats (CSV, txt, tab) I co开发者_StackOverflow中文版uld read each record out of a given table or query and then build the text file myself in autoit, not the simplest way of doing it, but it could work. The problem arises when trying to create the dBase file, I haven't a clue where to begin with that.
I am open to using JAVA, AutoIt, PHP, or Perl to accomplish my task.
I should note that I am fairly new to ADO. the syntax in ADO seems to elude me frequently. so, any and all help is appreciated, please refrain from the "Just google it" responses. if you have a link to share, or a resource that you have found helpful please post that as well, I am not allergic to reading or doing research. Sometimes it just makes more sense to ask for help.
Thanks,
Kyle
If you are open to using VBA, you could probably make it work with only a little code and the DoCmd-Object.
To export as CSV, have a look at DoCmd.Transfertext
To export to dBase, have a look at DoCmd.TransferDatabase
If you have questions about using those, just ask in the comments and I will provide more information.
This is a sort of bonkers idea, but if you already know Java, you may be able to get this to work with the JDBC-ODBC bridge. You'll first have to register your particular Access database as a named ODBC data source, as the bridge does not appear to support on-the-fly ODBC. I don't have a Windows machine on hand and don't remember the exact sequence of steps to do that, but it should be available from the ODBC driver manager.
精彩评论