2011-10-04 15:51
浏览 282


I have a problem while trying to connect to my SQL Server 2000 database using pdo_mssql with this line:

$connection = new PDO ('mssql:host=localhost;dbname=DNAME', 'user', 'password');

The exception is the following:

PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] General SQL Server error: Check messages from the SQL Server. (severity 5)' in C:\Inetpub\wwwroot\public\test.php:2 Stack trace: #0 C:\Inetpub\wwwroot\public\test.php(2): PDO->__construct('mssql:host=loca...', 'user', 'password') #1 {main} thrown in C:\Inetpub\wwwroot\public\test.php on line 2 

If I make the connection using the function mssql_connect() as follows, I obtain no error and my connection is correctly made:

$link = mssql_connect ('localhost', 'user', 'password');

Any idea? Where can I read the detailed error message? Thanks

图片转代码服务由CSDN问答提供 功能建议

尝试使用pdo_mssql连接到我的SQL Server 2000数据库时遇到问题:

  $ connection = new PDO('mssql:host = localhost; dbname = DNAME','user','password'); 
 \  n 


  PHP致命错误:未捕获异常'PDOException',消息'SQLSTATE [HY000]一般SQL Server错误:检查来自SQL的消息 服务器。  (严重性5)'在C:\ Inetpub \ wwwroot \ public \ test.php:2堆栈跟踪:#0 C:\ Inetpub \ wwwroot \ public \ test.php(2):PDO-> __ construct('mssql:  host = loca ...','user','password')在第2行的C:\ Inetpub \ wwwroot \ public \ test.php中抛出#1 {main} 


  $ link = mssql_connect('  localhost','user','password'); 

有什么想法吗? 我在哪里可以阅读详细的错误消息? 谢谢

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongweihuan8832 2011-10-04 16:14

    My database name had the character "-", removing it solved the problem!

    解决 无用
    打赏 举报

相关推荐 更多相似问题