How can I correct this error: Data source name not found and no default driver specified

后端 未结 2 1239
终归单人心
终归单人心 2021-01-25 18:26

I have a website that runs in Windows server, and it works perfectly fine. I tried to make a copy in my localhost but I get the error:

Warning: odbc_connect() [         


        
相关标签:
2条回答
  • 2021-01-25 18:55

    It's likely the shortcut for setting ODBC data sources is pointing to the 32bit data sources instead of 64bit.

    Go to control panel -> administrative tools --> select data sources(ODBC) --> then right click on that file --> go to properties --> in the shortcut tab -> change the path from

    %windir%\System32\odbcad32.exe
    

    to

    %windir%\SysWOW64\odbcad32.exe
    

    and make your connection. the driver for MS Access will work fine now.

    If it doesnt work, try to connect to the ODBC with a sentence like this:

    $conn = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\YourFolder\YourFile.mdb",'Youruser', 'YourPassword');
    

    The last 2 leave then just the the '' if you dont have any user or password

    0 讨论(0)
  • 2021-01-25 19:02

    I was getting the same error on PHP 7.0.8 64bit while trying to connect to an Access .mdb.

    I had to do two things:

    1. Install the 64bit version of "Microsoft Access Database Engine 2010 Redistributable" (even with Access 2016 installed I was getting your error). You can download the driver from:

      https://www.microsoft.com/en-us/download/details.aspx?id=13255

      Then, if you go to the ODBC Data Source Administrator, you should notice the 64bit version.

    2. Change the driver string to:

      Driver={Microsoft Access Driver (*.mdb, *.accdb)}

    Hope it helps other people.

    0 讨论(0)
提交回复
热议问题