PHP中使用PDO_MSSQL连接SQL Server


Connecting to SQL Server with PDO_MSSQL in PHP

我有一个问题,而试图连接到我的SQL Server 2000数据库使用pdo_mssql与这一行:

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

例外如下:

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 

如果我使用函数mssql_connect()建立连接,如下所示,我没有得到错误,我的连接是正确的:

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

任何想法?我在哪里可以看到详细的错误信息?由于

我的数据库名称有字符"-",删除它解决了问题!