« Previous Next »

Thread: My .vbs is Unable to connect to Access

Last post 01-16-2009 6:49 PM by Gary Dahl. 2 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 01-07-2009, 8:11 PM

    • Gary Dahl
    • Not Ranked
    • Joined on 12-19-2008, 10:52 AM
    • Laguna Hills, CA
    • Posts 8

    My .vbs is Unable to connect to Access

    Hello,

    I am attempting to have a .vbs file on the server connect to an Access database on that same server. I use the same connection script in my classic .asp pages and it works fine. But when I click on the .vbs file (on the server), I get this:

    Script:
    C:\website\myvbsfile.vbs
    Line: 42 
    [Microsoft][ODBC Driver Manager]Data Source Name not found and no default driver specified 
    Code: 80004005 Source: Microsoft OLE DB Provider for ODBC Drivers

    'here is the connection vbscript in the .vbs file:Dim objConn

    Set objConn = CreateObject("ADODB.Connection")
    objConn.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
        "DBQ=c:/databases/mydb.mdb"  

    objConn.Open 'line 42

    My Settings:
    Enable 32-bit Applications is set to True. I would like to attempt to connect with a system DSN, but the System DSN tab of the ODBC Data Source Administrator shows no system data sources. If I click the Add button, the Create New Data Source dialog only shows a SQL Server driver. The Drivers tab shows only the SQL Server Driver. However, the USER DSN tab DOES show the Microsoft Access Driver.

    Any Ideas?

  • 01-08-2009, 2:48 AM In reply to

    Re: My .vbs is Unable to connect to Access

    Start 32 bit command prompt (%windir%\system32\cmd.exe) or explicitly call 32bit cscript (%windir%\syswow64\cscript.exe)to launch your script. That should (hopefully) take care of your issue

    Jaroslav Dunajsky (MSFT, IIS)
  • 01-16-2009, 6:49 PM In reply to

    • Gary Dahl
    • Not Ranked
    • Joined on 12-19-2008, 10:52 AM
    • Laguna Hills, CA
    • Posts 8

    Re: My .vbs is Unable to connect to Access

    Thank you, very helpful. With your input we solved the problem and connected the .vbs file to our Access DB. I'm new to this (.vbs and IIS7) so I may have it wrong, but here is our solution for anyone who may be reading: 

    We put the following script into a batch (.bat) file (a text file with the extension changed from .txt to .bat):

    C:\WINDOWS\SysWOW64\wscript.exe "C:\websites\mysite\myvbsfile.vbs"

    As far as I understand, this tells the system to use the 32-bit driver. Instead of clicking on the myvbsfile.vbs file directly, I now run the batch file and IT runs the .vbs file.

    Thanks again.

Page 1 of 1 (3 items)
Microsoft Communities