QODBC SQL Server sp_cursoropen "The cursor was not declared" error
-
I am using QODBC to connect to MS SQL Server. Everything works fine with normal Statements, executing stored procedures, that I've created in SQL Server and so on... Now I created a stored procedure in Visual Studio and did implement it via common language runtime (CLR) into SQL Server. It creates me an assembly and a stored procedure in SQL Server. I can execute this stored procedure in SQL Server Management Studio without any problem. But when I called it from my QT programm it throws the error:
[Microsoft][SQL Server Native Client 11.0][SQL Server]The request for procedure 'HelloWorldExp' failed because 'HelloWorldExp' is a procedure object. [Microsoft][SQL Server Native Client 11.0][SQL Server]The cursor was not declared. QODBC3: Unable to execute statement
I did some research and found the request in SQl Server profiler. In SQL Server Profiler the SQL request lokks like this:
declare @p1 int set @p1=0 declare @p3 int set @p3=8 declare @p4 int set @p4=8193 declare @p5 int set @p5=0 exec sp_cursoropen @p1 output,N'EXEC HelloWorldExp ''1''',@p3 output,@p4 output,@p5 output select @p1, @p3, @p4, @p5
When I use another sample programm using ODBC without QT, the SQl request looks like:
HelloWorldExp ''1'''
This will be executes without any error.
Is there a setting that tells QT not to send the whole overhead?
-
I am using QODBC to connect to MS SQL Server. Everything works fine with normal Statements, executing stored procedures, that I've created in SQL Server and so on... Now I created a stored procedure in Visual Studio and did implement it via common language runtime (CLR) into SQL Server. It creates me an assembly and a stored procedure in SQL Server. I can execute this stored procedure in SQL Server Management Studio without any problem. But when I called it from my QT programm it throws the error:
[Microsoft][SQL Server Native Client 11.0][SQL Server]The request for procedure 'HelloWorldExp' failed because 'HelloWorldExp' is a procedure object. [Microsoft][SQL Server Native Client 11.0][SQL Server]The cursor was not declared. QODBC3: Unable to execute statement
I did some research and found the request in SQl Server profiler. In SQL Server Profiler the SQL request lokks like this:
declare @p1 int set @p1=0 declare @p3 int set @p3=8 declare @p4 int set @p4=8193 declare @p5 int set @p5=0 exec sp_cursoropen @p1 output,N'EXEC HelloWorldExp ''1''',@p3 output,@p4 output,@p5 output select @p1, @p3, @p4, @p5
When I use another sample programm using ODBC without QT, the SQl request looks like:
HelloWorldExp ''1'''
This will be executes without any error.
Is there a setting that tells QT not to send the whole overhead?
@Rudl
This looks like a nasty one. I don't know whether you can cause Qt to issue different SQL code (how exactly does your code call the procedure?). And I'm not sure even if you did it would affect the behaviour. It sounds like it ought to be working.I know this sounds lame, but have you tried restarting your SQL Server since you first got this error and try again on a freshly connected database?
-
Thank you for your replay.
I call the procedure like this:
QSqlQuery query; query.exec("EXEC HelloWorldExp '1' ");
Of course, when I execute this code on SQL Server directly:
declare @p1 int set @p1=0 declare @p3 int set @p3=8 declare @p4 int set @p4=8193 declare @p5 int set @p5=0 exec sp_cursoropen @p1 output,N'EXEC HelloWorldExp ''1''',@p3 output,@p4 output,@p5 output select @p1, @p3, @p4, @p5
I get the same error. When I execute just:
EXEC HelloWorldExp '1'
everything works fine.
I did restart the SQL Server and I have the same effect.
When I create the stored procedure in Visual Studio and implement it via CLR into SQL Server, the stored procedure is protected.
So I can't see or change the stored procedure. With the workaround to create another stored procedure in SQL Management Studio, that calls the "HelloWorldExp" it works.It seams sp_cursoropen has a problem with CLR created procedures.