Advertisement
Guest User

sample php script using SQLSRV drivers

a guest
May 2nd, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2.  
  3. $serverName = "server";
  4. $connectionInfo = array("UID"=> "user", "PWD" =>"pass", "Database"=>"sample_db");
  5. $conn = sqlsrv_connect( $serverName, $connectionInfo);
  6.  
  7. if( $conn )
  8. {
  9.     $sql = "db_AbbTest";
  10.     $r = sqlsrv_query($conn, $sql, null, array(
  11.             'Scrollable' => SQLSRV_CURSOR_STATIC,
  12.             'SendStreamParamsAtExec'    => true
  13.         ));
  14.     var_dump($r);
  15.         while( $obj = sqlsrv_fetch( $r))
  16.         {
  17.               var_dump($obj);
  18.               var_dump(sqlsrv_fetch_array($r));
  19.         }
  20.      echo "Connection established.\n";
  21. }
  22. else
  23. {
  24.      echo "Connection could not be established.\n";
  25.      die( print_r( sqlsrv_errors(), true));
  26. }
  27.  
  28. //-----------------------------------------------
  29. // Perform operations with connection.
  30. //-----------------------------------------------
  31.  
  32. /* Close the connection. */
  33. sqlsrv_close( $conn);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement