通过ODBC错误连接到MSSQL数据库

Where to start..

  • I have a server with windows 2008 R2 standard 32 bits.
  • On that server ISS 7 is installed and a php site is added but requires databases.
  • Made an sql database on that server wich is called 'test'.
  • ODBC connection is made and tested and it succeeded.
  • Now when I use this php code to connect to the server it gives me:

    Can not connect because the target machine actively refused it.

php code:

<?
### Database    ###
$user = "*****"; //database user
$pass = "*****";    //database password
$host = "localhost";   //database location
$db = "test";     //database name
##mysql_connect ("$host","$user","$pass");
##mysql_select_db("$db");
$dbConn = odbc_connect("$db","$user","$pass","$host") or die(odbc_errormsg());
?>

The password and username are correct but the error still remains.

Any help is appreciated!

Have you set your datasource using administrative tools, data sources, System DSN?

if not i'm sure it won't find the database.

see this link: http://support.microsoft.com/kb/305599