VBS访问选择到txt

时间:2014-04-30 07:18:55

标签: vbscript ms-access-2010

我想通过vbs将访问sql写入txt文件。脚本工作正常,除了我没有得到任何输出。

    Call OpenRecordset("SELECT * FROM [Table 1]")

    dbRec.Close:   dbCon.Close

   'WScript.Quit

'Main End


Private Sub OpenRecordset(ByRef dbSql)

    Set dbCon = CreateObject("ADODB.Connection")
    Set dbRec = CreateObject("ADODB.Recordset")

    With dbCon 'Verbindung zur Datenbank herstellen
        .Mode = adModeReadWrite
        .CursorLocation = adUseClient
        '.Provider = "Microsoft.Jet.OLEDB.4.0"  '*.mdb
        .Provider = "Microsoft.ACE.OLEDB.12.0" '*.accdb ACCESS 2007
        .Properties("Data Source") = dbPath
        .Properties("Persist Security Info") = False
        .Properties("User ID") = "***"
        .Properties("Password") = "***"
        .Properties("Jet OLEDB:System database") = dbSystem
        .Open
    End With

    With dbRec 'Einen Recordset für die Datensätze erstellen
        .Source = dbSql
        .ActiveConnection = dbCon
        .CursorLocation = adUseClient
        .CursorType = adOpenKeyset
        .LockType = adLockOptimistic
        .Open
    End With
End Sub

我该怎么做?提前谢谢。

0 个答案:

没有答案