简体   繁体   English

adodb与sql server odbc的连接问题

[英]adodb with sql server odbc connection problem

ADODB Error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ADODB错误:[Microsoft] [ODBC驱动程序管理器]找不到数据源名称,并且未指定默认驱动程序

I downloaded the odbc driver for PHP. 我下载了用于PHP的odbc驱动程序。 I pasted that driver in the PHP ext directory, then I get the error. 我将该驱动程序粘贴到PHP ext目录中,然后收到错误消息。 Can anybody help me? 有谁能够帮助我?

A few things that I would try, 我会尝试的一些事情,

  • Make sure that the extension is included in your php.ini 确保扩展名包含在您的php.ini中
  • Make sure that you've extracted the db driver to the right place c:\\windows\\drivers in some cases! 在某些情况下,请确保已将数据库驱动程序提取到正确的位置c:\\ windows \\ drivers!
  • Have you rebooted? 你重启了吗? As you'll need to reboot your server to load the driver, I assume you have as you get the error :) 由于您需要重新引导服务器以加载驱动程序,因此我假设您已经收到错误消息了:)

As the comment above states, which driver you are using, it's version, and which database you're connecting to would also be handy to know :) 如上面的注释所述,您正在使用哪个驱动程序,它的版本以及要连接到哪个数据库也很容易知道:)

I assume that you're using PHP5 to connect to MSSQL2005. 我假设您正在使用PHP5连接到MSSQL2005。 In which case the driver is really dodgy, or was when I last worked with it. 在这种情况下,驱动程序确实很狡猾,或者是我上次使用它时。 It would maintain a connection about 1/3 tries. 它将维持大约1/3次尝试的连接。 What web server are you using? 您正在使用什么Web服务器? As I recall when we were using IIS to serve the PHP+MSSql we had some configuration to do in the IIS setup. 我记得当我们使用IIS来提供PHP + MSSql时,我们在IIS安装程序中要做一些配置。

try: 尝试:

# config file
$oODBC = new stdClass();
$oODBC->driver = "odbc_mssql";
$oODBC->dns = "Driver={SQL Server};Server=127.0.0.1;Database=yourdatabhase;";
$oODBC->user = "username";
$oODBC->pass = "password";

# connect
$mDB = $oODBC;
$db =& ADONewConnection($mDB->driver); // ex: odbc_mssql
$db->PConnect($mDB->dns, $mDB->user, $mDB->pass);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM