schema.ini file to export from Access

2019-08-02 07:51发布

问题:

I'm exporting from an Access DB via VBscript and want to try using a Schema.ini file. I have a batch program that fires off a vbscript file that opens the Access DB and does the export. My vbscript filename is export.vbs.

If I have:

DoCmd.TransferText acExportDelim, "", "table", "C:\output\table.csv"

I notice while the export is happening a file gets automatically created "export.ini".

If I have

DoCmd.TransferText acExportDelim, "Schema.ini", "table", "C:\output\table.csv"

I get an error talking about "The text file spec 'Schema.ini" does not exist." even though in the same directory this is all happening in I have a Schema.ini file there. What am I missing?

Thanks!

回答1:

You need to go about it a different way ( Create comma separated file (csv) from access - scheduled daily from windows )

Set cn = CreateObject("ADODB.Connection")

cn.Open "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=z:\Docs\test.accdb"

sSQL = "select * into " 
sSQL= sSQL & "[text;database=z:\docs\;FMT=Delimited;HDR=Yes].[csvfile.csv]"
sSQL= sSQL & " from table1"

cn.Execute sSQL