This error generally happens because an ODBC connection can only have one active cursor at a time.
When you use the EXEC command to select data from a table, a cursor object is created, if you don't fetch the data from this cursor and you try to execute another EXEC command using the same connection, you will get this error message.
To work around this issue, there are two possibilities:
1. Make sure to read the rest data from the pending result set before we send the next EXEC command:
cursor_odbc_first = exec(conn_odbc,query)
cursor_data = fetch(cursor_odbc_first);
cursor_odbc_second = exec(conn_odbc,query)
2. Use the Multiple Active Result Sets (MARS) connection setting to enable multiple active result sets in a connection.
The following link on the MSDN support page provides additional information:
<http://msdn2.microsoft.com/en-us/library/ms345109.aspx>
Best Answer