PDO_ODBC: Data source name not found and no default driver specified

后端 未结 1 373
-上瘾入骨i
-上瘾入骨i 2020-12-21 13:21

I\'m trying to access an ODBC connection in PHP via PDO_ODBC. This is my code:

$db = new PDO(\'odbc:MyDSN\', \'\', \'\');

And I\'m getting this

相关标签:
1条回答
  • 2020-12-21 14:11

    There are actually two separate Microsoft ODBC Administrator apps, one for 32-bit and one for 64.

    As this KB article explains:

    The 32-bit version of the Odbcad32.exe file is located in the %systemdrive%\Windows\SysWoW64 folder.

    The 64-bit version of the Odbcad32.exe file is located in the %systemdrive%\Windows\System32 folder.

    Nope, not a typo -- the 32-bit version is in the SysWoW64 folder and the 64-bit is in the System32 folder. (o_O)

    I was running a 64-bit web server which was checking the 64-bit ODBC library for the DSN, whereas I had it in the 32-bit. Downgrading the server did the trick.

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