Drivers sqlsrv

Drivers sqlsrv - PHP - Programmation

Marsh Posté le 24-06-2011 à 15:52:45    

Bonjour,
si je fais ceci:

Code :
  1. $serverName = "xxx";
  2. $connectionOptions = array("Database"=>"xxx","UID"=>"xxx","PWD"=>"xxx","CharacterSet"=>"UTF-8" );
  3.  
  4. $conn = sqlsrv_connect( $serverName, $connectionOptions);
  5.  
  6. if( $conn === false) die(sqlsrv_errors());
  7. $sql = "select top 10 * from clients";
  8. $res = sqlsrv_query( $conn, $sql);
  9. while( $row = sqlsrv_fetch_array( $res, SQLSRV_FETCH_ASSOC)){
  10.     print_r($row);
  11. }


ca marche très bien.
 
Par contre si je fais ceci:

Code :
  1. $serverName = "xxx";
  2. $connectionOptions = array("Database"=>"xxx","UID"=>"xxx","PWD"=>"xxx","CharacterSet"=>"UTF-8" );
  3.  
  4. $conn = sqlsrv_connect( $serverName, $connectionOptions);
  5.  
  6. if( $conn === false) die(sqlsrv_errors());
  7. $sql = "use MADB;select top 10 * from clients";
  8. $res = sqlsrv_query( $conn, $sql);
  9. while( $row = sqlsrv_fetch_array( $res, SQLSRV_FETCH_ASSOC)){
  10.     print_r($row);
  11. }


(j'ajoute juste "use MADB;" à ma query)
Ça ne me retourne rien !  [:cerveau ouch]  
comment ceci est-il possible ?

Reply

Marsh Posté le 24-06-2011 à 15:52:45   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed