Sql server connction dont work

CDbConnection failed to open the DB connection: SQLSTATE[08001]: [Microsoft][SQL Server Native Client 11.0]Named Pipes Provider: Could not open a connection to SQL Server [53].

C:\wamp64\www\config\framework\db\CDbConnection.php(399)

in the Database.php i’m using this connection:

return array(

'connectionString' => 'sqlsrv:server=10.1.X.XX;database=database',
		'username' => 'desaUSER',
		'password' => 'desarrollopass',
		'charset' => 'utf8',

);

II’m using WAMP PHP apache server

https://stackoverflow.com/questions/44938273/error-connection-failed-sqlstate-08001-occurs-when-creating-an-odbc-connec/44938570 ?

if i make a simple index. php page with this exercise conection, :slight_smile:

<?php $serverName ="10.1.XX.XX"; $connectionInfo = array("Database" =>"REALSTATEXX" ,"UID"=>"USerxx" ,"PWD"=>"PassXX" ); $conn=sqlsrv_connect( $serverName, $connectionInfo); $ruta=__FILE__; if ( $conn ) { echo"connected."; echo "ruta : ".$ruta ; }else{ echo"connexion Fail."; die(print_r(sqlsrv_errors(),true)); } ?>

the result is :

mensaje%20conexion

But when make this connection on de database.php of yii don’t work

https://stackoverflow.com/a/36212561

CDbException

CDbConnection failed to open the DB connection: SQLSTATE[08001]: [Microsoft][SQL Server Native Client 11.0]TCP Provider: Se produjo un error durante el intento de conexión ya que la parte conectada no respondió adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexión establecida ya que el host conectado no ha podido responder.

C:\wamp64\www\config\framework\db\CDbConnection.php(399)

387                 throw new CDbException('CDbConnection.connectionString cannot be empty.');
388             try
389             {
390                 Yii::trace('Opening DB connection','system.db.CDbConnection');
391                 $this->_pdo=$this->createPdoInstance();
392                 $this->initConnection($this->_pdo);
393                 $this->_active=true;
394             }
395             catch(PDOException $e)
396             {
397                 if(YII_DEBUG)
398                 {
399                     throw new CDbException('CDbConnection failed to open the DB connection: '.
400                         $e->getMessage(),(int)$e->getCode(),$e->errorInfo);
401                 }
402                 else
403                 {
404                     Yii::log($e->getMessage(),CLogger::LEVEL_ERROR,'exception.CDbException');
405                     throw new CDbException('CDbConnection failed to open the DB connection.',(int)$e->getCode(),$e->errorInfo);
406                 }
407             }
408         }
409     }
410
411     /**

this is de error that send the sistem when change the conection from mysql to sql server

Alvaro Jaque Martinez Consultor Tecnico JdEdwards O.W. Cel:+569-94195851

Stack Trace

#0

It looks like your recent attempt used the TCP Provider instead of the Named Pipe provider. Perhaps it’s a SQL Server instance using some other port? Why not try the plain PHP code in the post I linked to. I think this is not a Yii problem (not doing programming nowadays).