title: Can't retrieve data from MS SQL with PDO
body: <p>I use PDO on my local computer to connect to MS SQL server to use prepare statements. The driver is installed properly and can connect to database. Here's the code:</p>
  
  <pre><code>try {
      $con = new PDO("sqlsrv:Server={$host};Database={$db_name}", $username, $password);
      }
  catch(PDOException $exception){
  echo "Connection error: " . $exception-&gt;getMessage();
  }
  
  $query = "SELECT TOP 10 ClientID FROM CLIENT";
  $stmt = $con-&gt;prepare($query);
  $stmt-&gt;execute();
  $num = $stmt-&gt;rowCount();
  print $num;
  </code></pre>
  
  <p>From SSMS the query returns as it should, but nothing from the code as it prints -1 as the result of <code>$num</code>. If i change the query to <code>SELECT @@VERSION</code> it prints the version properly but not my query. My query is right from SSMS and PDO can connect to server but can't figure out where the problem is it's so frustrating please help.</p>