Invalid cursor state, SQL state 24000 in SQLExecDirect
database-cursor, odbc, php, sql-server, stored-procedures
Solution
Open two handles to the database. ODBC probably maintains the cursor in the handle.
Problem
I need to call two stored procedures in sequence via ODBC in PHP: ``` #run stored procedure 1 $query = "Shipped_Not_Shipped_Rep ".$_GET['rep_id']; $result = odbc_exec($dbh, $query); odbc_result_all($result); #run stored procedure 2 $query = "Shipped_Not_Shipped_Account ".$_GET['account_id']; $result = odbc_exec($dbh, $query); odbc_result_all($result); ``` I'm getting this error in PHP after the second stored procedure call: Warning: odbc_exec() [function.odbc-exec]: SQL error: [unixODBC][FreeTDS][SQL Server]Invalid cursor state, SQL state 24000 in SQLExecDirect If I re-arrange the order I call the stored procedures, it is always the second that errors. Is there a way to, idk, reset the cursor position between calls? A little out of my element here.