MS Access:在其他路径中为CSV文件选择* Into

问题描述 投票:1回答:1

我需要将CSV数据复制到Access表中。 TransferText按预期工作,但比“Select * Into”慢得多。 500K记录,43列(不是我的数据)。

以下工作根据需要,但仅当CSV文件与数据库位于同一路径上时(在本例中为strPath)。

strFile = "testfile.csv"
strPath = CurrentProject.Path
strPath2 = CurrentProject.Path & "\Backend_Data\"

strSQL = "SELECT * INTO TempItem FROM [Text;HDR=NO;FMT=Delimited(,);Database=" & strPath & "].[" & strFile & "];"
db.Execute (strSQL)

CSV文件将在strPath2(\ Backend_Data)中登陆。在strFile之前将strPath2添加到上面的strSQL不起作用或抱怨。

这是一个SQL语法问题,还是只需要将CSV文件保存在与数据库相同的路径中?

ms-access access-vba
1个回答
0
投票

CurrentProject.Path没有反斜杠,所以请尝试:

strPath2 = CurrentProject.Path & "\Backend_Data"

strSQL = "SELECT * INTO TempItem FROM [Text;HDR=NO;FMT=Delimited(,);Database=" & strPath2 & "].[" & strFile & "];"
db.Execute (strSQL)
© www.soinside.com 2019 - 2024. All rights reserved.