开发者

PHP PDO & SQL Server connection with dblib issues

I have experience about PDO but I was working with MySQL so far. I needed to work with PDO + SQL Server but seems something weird going on.

<?php
$dsn = 'dblib:dbname=my_db;host=127.0.0.1'; //dbname and host is on different server, not localhost
$user = 'username';
$password = 'password';
try {
    $db = new PDO($dsn, $user, $password);
    $db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );  
}
catch(PDOException $e) {  
    echo $e->getMessage();  
} 
?>

I'm getting following error;

SQLSTATE[HY000] General SQL Server error: Check messages from the SQL Server. (severity 5)

I'm really confused right now what is wrong with my code. Dblib is installed on the server, I didn't even make any queries and this code should work just fine. Where ever I checked over the internet every time it is the same code. That's why I'm sure that there is nothing wrong with my code.

I will be glad if anyone who has experience about it could help me out with it.

P.S. I'm aware of the fact that dblib is in experimental state still it should be able to establish a connection.

Thank you for your help and time in advance.

EDIT:

Problem is partially solved. Thanks to Uzay Teknoloji A.Ş. they've created SQL Server 2008 R2 database for me to test establishing SQL Server connection. The database I was trying to connect before was SQL Server 200开发者_如何学运维0. It seems SQL Server 2000 doesn't support dblib.


I would like to close the question. As I wrote on my question problem was with PHP dblib not supporting SQL 2000 so I couldn't connect.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜