none
PDO Exception, error to connect PHP 5.3.8 + Sql Server 2008 : Error connecting to SQL Server( ! ) PDOException: SQLSTATE[08001]: [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [53]

    Question

  • Hello,

    i'm try to stablish a connection with a sqlserver database, but i get a PDO Exception about not open a connection:

    Error connecting to SQL Server( ! ) PDOException: SQLSTATE[08001]: [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [53]. in C:\wamp\www\cursos\conexphpsql.php on line 10 Call Stack #TimeMemoryFunctionLocation 10.0015371232{main}( )..\conexphpsql.php:0 20.0015372104PDO->__construct( )..\conexphpsql.php:10

     

    The Fileconexphpsql.php contain

    <?php

       $serverName = "(xxx)";

       $database = "usr";



       // Get UID and PWD from application-specific files.

       $uid = "sa";

       $pwd = "xxx";



       try {

          $conn = new PDO("sqlsrv:server=$serverName;Database = $database", $uid, $pwd);

          $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );

       }



       catch( PDOException $e ) {

          die( "Error connecting to SQL Server" . $e->xdebug_message );

       }



       echo "Connected to SQL Server\n";



       $query = 'select * from t_rotacionclientesean';

       $stmt = $conn->query( $query );

       while ( $row = $stmt->fetch( PDO::FETCH_ASSOC ) ){

          print_r( $row );

       }



       // Free statement and connection resources.

       $stmt = null;

       $conn = null;

    ?>

    Wednesday, November 02, 2011 1:35 AM

Answers

All replies