Question
Ramesh Ramachandran · Sep 23, 2020

ODBC Invalid cursor state Error

We use ExecureProcedure() to execute a stored procedure which returns a result set. But we see lot of "Invalid cursor state" errors when the result set is empty.  The connection to SQL server database is made through ODBC. 

ERROR #6022: Gateway failed: Fetch. + ERROR <Ens>ErrGeneral: SQLState: (24000) NativeError: [0] Message: [Microsoft][ODBC Driver 11 for SQL Server]Invalid cursor state 

Here is the code snippet from the business operation class which uses EnsLib.SQL.OutboundAdapter  

do ..Adapter.DSNSet(DataSourceName)

set sp = "{call sqlstoredprocedure(?,?,?)}"
set tSC = ..Adapter.ExecuteProcedure(.pResults, .out, sp, "iii", p1,p2,p3)

Looking at the ODBC documentation, error 24000 means "A cursor is already opened on the statement handle." 

There is no error when we execute the proc directly on SQL Server. Did anyone come across this issue?

Please provide your suggestion to get this fixed.  

00
0 0 80 2