douyuan4825 2016-04-20 20:53
浏览 198

PHP 7 x64 ODBC错误连接到MSSQL数据库

Getting the following error when testing an upgrade to PHP7 x64:

odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I've installed the following:

  • PHP 7.0.0 x64
  • Microsoft ODBC Driver 11 for SQL Server x64
  • Microsoft Visual C++ 2015 Redistributable x64
  • Microsoft Visual C++ 2015 Redistributable x86
  • The (thread-safe) preview of the PHP 7 MSSQL drivers: https://github.com/Azure/msphpsql

I have uncommented/added the following lines of my phpini:

  • extension=php_pdo_mysql.dll (uncommented)
  • extension=php_odbc.dll (added)
  • extension=php_sqlsrv_7_ts.dll (added)
  • extension=php_pdo_sqlsrv_7_ts.dll (added)

Things to consider:

  • I can see that the modules are indeed loaded in phpinfo.
  • I've added the ODBC connection and can see it in System DSN.
  • I am successfully able to connect via sqlsrv_connect() but not odbc_connect(), which is what all our previous PHP 5.6 scripts are using.

Can't seem to find the answer anywhere else. Any help would be appreciated. Thanks.

  • 写回答

1条回答 默认 最新

  • duanbi2760 2016-04-21 16:50
    关注

    I seem to have solved my own issue.

    Turns out, the ODBC_CONNECT string uses an explicit DSN name and not a database, apparently...

    Previously my ODBC Connect string was $conn = odbc_connect('DB',$DBUSER, $DBPASS) and my ODBC Data Source was "SERVERNAME"

    Once I changed the ODBC Data Source name to match the DB name, it worked.

    评论

报告相同问题?

悬赏问题

  • ¥15 方程如何编到C语言!
  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了