Handling errors in a stored proc called from c++ program using db-library

Handling errors in a stored proc called from c++ program using db-library

Post by Sukanta Ka » Sat, 06 Oct 2001 06:54:26



Hi!,
I am calling a stored proc from my c++ program. I connect
to sql server using db library.

I am running stored procedure(sp_Proc) in asynchronusly
using dbsqlsend, dbdataready and dbsqlok.

My problem is that, my stored proc is failing at random
places. I mean dbsqlsend is returning SUCCEED, dbdataready
is returning true, but dbsqlok is returning FAILED. But I
am not able to get the error message/number from the
stored procedure. I have registered dbmsghandle and
dberrhandle. But neither of these are reporting any error.

I have also tried to bind the first column using dbbind to
get the error message from stored proc, but it hangs at
this point.

I would like to return the error code from stored proc and
receive it in the C++ program.

Can anyone help me. Thanks in advance.

- Sukanta

 
 
 

Handling errors in a stored proc called from c++ program using db-library

Post by Erland Sommarsko » Tue, 09 Oct 2001 07:35:53



> I am calling a stored proc from my c++ program. I connect
> to sql server using db library.

> I am running stored procedure(sp_Proc) in asynchronusly
> using dbsqlsend, dbdataready and dbsqlok.

> My problem is that, my stored proc is failing at random
> places. I mean dbsqlsend is returning SUCCEED, dbdataready
> is returning true, but dbsqlok is returning FAILED. But I
> am not able to get the error message/number from the
> stored procedure. I have registered dbmsghandle and
> dberrhandle. But neither of these are reporting any error.

> I have also tried to bind the first column using dbbind to
> get the error message from stored proc, but it hangs at
> this point.

> I would like to return the error code from stored proc and
> receive it in the C++ program.

I wouldn't say that I have much intelligent to offer. dbsqlok could
be returning FAIL for some other reason than a stored-procedure error,
but I cannot think of what that could be.

If you switch from asynchrouns execution to synchronous with dbsqlexec,
does this change the scene?

--
Erland Sommarskog, Abaris AB

SQL Server MVP