0
votes

I have a php file that im using odbc to get data from MSSQL 2008. I got everything working; however, when I try to run another query after the first one I get this error:

Warning: odbc_exec(): SQL error: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt, SQL state S1000 in SQLExecDirect in C:\wamp\www\3.php on line 7

if ($conn)
{
//there will be no return output for this one just want to run it to refresh the sales data
  $query1="my query code here"; 
  $result=odbc_exec($conn, $query1);

  $query2="my other query code here"; 
  $result=odbc_exec($conn, $query2);

}
1
Now I got it to work by running one <?PHP query one, close connection ?> then opening the connection again and running the other, it works perfectly; however isnt it not practical to open and close connections when you dont have to or can I just leave it like that. - user3890598
you should be able do use odbc_free_result after using the first result set, instead of closing the connection. - Laurence
: Use of undefined constant odbc_free_result - assumed 'odbc_free_result' in C:\wamp\www\3.php on line 26 - user3890598
odbc_free_result(); thats what I added in my code. Its not working still Warning: odbc_free_result() expects parameter 1 to be resource, integer given in C:\wamp\www\3.php on line 26 - user3890598
nevermind I fixed it its: odbc_free_result($result); - user3890598

1 Answers

0
votes

I post this in another question and I think could be useful to you.

function foo($sql){
   $res = odbc_exec($this->dbconn, $sql);
   if (odbc_error () and $res===false ) {
       throw new Exception odbc_errormsg($this->dbconn));

   }
    return $res;
}