Connecting to MS SQL Server 2012

Dear All,

I would be really grateful if someone could help me with the following error:

I can connect using the following code




<?php

$serverName = "localhost\\sqlexpress"; //serverName\instanceName

$connectionInfo = array( "Database"=>"db", "UID"=>"sa", "PWD"=>"sapwd");

$conn = sqlsrv_connect( $serverName, $connectionInfo);


if( $conn ) {

     echo "Connection established.<br />";

}else{

     echo "Connection could not be established.<br />";

     die( print_r( sqlsrv_errors(), true));

}

?>



but not through yii using the following connection string




		'db'=>array(

			'connectionString' => 'sqlsrv:Server=localhost\\SQLEXPRESS; Database=db',

			'username' => 'sa',

			'password' => 'sapwd',

		),



giving the following error:




CDbConnection failed to open the DB connection: SQLSTATE[08001]: [Microsoft][ODBC Driver 11 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [2]. 



please note changing case doesn’t help

PHP Version 5.5.28

SQL Server Express 2012 sp2

Dude, I think you need install a PDO driver to M$ SQL.