创建语句以使用Vbscript运行Microsoft Access查询

时间:2018-02-21 05:22:27

标签: sql vbscript

我到目前为止是一个打开Microsoft Access应用程序的查询,但我想打开并运行SQL查询本身并关闭应用程序。像

这样的查询
SELECT S2iOSGISAcquisitionCSV.Agencia, 
       S2iOSGISAcquisitionCSV.Mercado, 
       S2iOSGISAcquisitionCSV.[Nome Produtor], 
       S2iOSGISAcquisitionCSV.Dispositivo
FROM S2iOSGISAcquisitionCSV; 

我可以在哪里发表声明?谢谢

Dim sAcc
    Dim sFrontEnd
    Dim sSec
    Dim sUser
    Dim objShellDb
    Dim sComTxt
    Dim rs

sAcc = "C:\Program Files\Microsoft Office 15\root\office15\msaccess.exe"
 '"C:\Program Files\Microsoft Office\OFFICE11\msaccess.exe"

sFrontEnd = "C:\Users\User\Desktop\TABELA_DE_DADOS.accdb"


Set objShellDb = CreateObject("WScript.Shell")
'Set rs = createObject("SELECT* FROM S2iOSGISAcquisitionCSV");

sComTxt = chr(34) & sAcc & chr(34) &_
      " " & chr(34) & sFrontEnd & chr(34) 
if isNull(sSec)=False AND sSec<>"" Then
    sComTxt = sComTxt & " /wrkgrp " & chr(34) & sSec & chr(34)
End if
if isNull(sUser)=False AND sUser<>"" Then
    sComTxt = sComTxt & " /user " & sUser
End if
 objShellDb.Run sComTxt 
' rs.Run sComTxt

0 个答案:

没有答案