PDO_ODBC:找不到数据源名称,并且未指定默认驱动程序 [英] PDO_ODBC: Data source name not found and no default driver specified

查看:186
本文介绍了PDO_ODBC:找不到数据源名称,并且未指定默认驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过PDO_ODBC访问PHP中的ODBC连接.这是我的代码:

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

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

我收到此错误:

SQLSTATE [IM002] SQLConnect:0 [Microsoft] [ODBC驱动程序管理器]数据 找不到源名称,也未指定默认驱动程序

SQLSTATE[IM002] SQLConnect: 0 [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

我知道DSN可以正常工作,因为我可以在带有pyodbc的Python中使用它.类型为用户DSN-是否需要为系统DSN?我没有指定驱动程序,因为我认为ODBC正在将其抽象化,但是也许我需要这样做吗?底层数据库是Oracle(如果有帮助的话).

I know the DSN is working because I can use it in Python with pyodbc. The type is User DSN - does it need to be a System DSN? I'm not specifying a driver because I figured ODBC was abstracting that away, but maybe I need to? The underlying DB is Oracle, if that helps.

谢谢!

推荐答案

实际上有两个单独的Microsoft ODBC Administrator应用程序,一个用于32位,另一个用于64位.

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

KB文章所述:

Odbcad32.exe文件的32位版本位于 %systemdrive%\ Windows \ SysWoW64文件夹.

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

64位版本的 Odbcad32.exe文件位于%systemdrive%\ Windows \ System32中 文件夹.

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

不是,不是拼写错误-32位版本位于SysWoW64文件夹中,而64位版本位于System32文件夹中. (o_O)

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

我正在运行一个64位Web服务器,该服务器正在检查64位ODBC库中的DSN,而我却在32位中使用它.降级服务器可以解决问题.

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.

这篇关于PDO_ODBC:找不到数据源名称,并且未指定默认驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆