none
VBS Connetion String Problem for Acess 2010

    Question

  • Hi Experts,

    I am new here. I am writing a VBS script by using CreateObject( "ADODB.Connection" ) to access Access 2010. The connection is always failed. Here is my code segment.

    ' --------------------------------- begin dbTest.vbs ------------------------------------------------------

    ' "t1.accdb" is created from Access 2010 application.

    ' Const ConnString = "PROVIDER=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=C:\\Users\xx\t1.accdb;"
    Const ConnString = "Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\\Users\xx\t1.accdb;"

    Dim Conn: Set Conn = CreateObject( "ADODB.Connection" )
    Conn.Open ConnString                                  '    ---------- it's not working --------------
    Conn.Close
    Set Conn = Nothing

    ' --------------------------------- end of dbTest.vbs ------------------------------------------------------

    The libs listed below are all in the system. I also read "Access Database Engine 2010 Redistributable" and make sure reinstall "AccessDatabaseEngine.exe". And it's still not working. I am wondering it's reference problem, but how do I check what "cscript/wscript" is looking for?  Your help will be greatly appreciated if you could guide me to nail down the problem.

    C:\Program Files (x86)\Microsoft Office\Office14\msacc.olb                            # Access Object lib
    C:\Program Files (x86)\Common Files\Microsoft Shared\Office14\acedao.dll      # DAO lib
    C:\Program Files (x86)\Common Files\System\ADO\msado25.tlb                     # ADODB lib

     

     

    Friday, October 28, 2011 6:31 AM

Answers

  • Hi,

    references are not the problem here because you are working from with VBscript, not from Access itself. Do you receive any errors? The problem here might be in your connection string. Try to change it to:

    Const ConnString = "Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\\Users\xx\t1.accdb;Uid=Admin;Pwd=;"


    Andrey V Artemyev | Saint-Petersburg, Russia
    Russian blog artemyev.biztoolbox.ru
    English blog enblog.biztoolbox.ru
    • Marked as answer by Bruce Song Monday, November 07, 2011 11:06 AM
    Friday, October 28, 2011 6:42 AM