我正在尝试使用 VBScript 从文本文件加载查询到 MS Access 查询集合。我正在使用这样的东西: 代码源自Here .
for each myFile in folder.Files
objecttype = fso.GetExtensionName(myFile.Name)
objectname = fso.GetBaseName(myFile.Name)
WScript.Echo " " & objectname & " (" & objecttype & ")"
if (objecttype = "form") then
oApplication.LoadFromText acForm, objectname, myFile.Path
elseif (objecttype = "bas") then
oApplication.LoadFromText acModule, objectname, myFile.Path
elseif (objecttype = "mac") then
oApplication.LoadFromText acMacro, objectname, myFile.Path
elseif (objecttype = "report") then
oApplication.LoadFromText acReport, objectname, myFile.Path
elseif (objecttype = "sql") then
'oApplication.LoadFromText acQuery, objectname, myFile.Path
' Add create querydef code here
end if
next
但我不确定如何使用 VBScript 创建查询定义。
有什么想法吗?
注意: 我最初使用这样的方式导出到文件:
For Each myObj In oApplication.CurrentDb.QueryDefs
Set f = fso.CreateTextFile(sExportpath & "\" & myObj.Name & ".sql", True)
f.WriteLine(myObj.SQL)
f.Close
Next
最佳答案
这将保存查询定义
For i = 0 To db.QueryDefs.Count - 1
Application.SaveAsText acQuery, db.QueryDefs(i).Name, sExportpath & "\" & db.QueryDefs(i).Name & ".sql"
Next i
然后 LoadFromText 应该工作
关于ms-access - MS Access 查询的 Application.LoadFromText 的替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/859530/