sql server odbc:
After your call to SQLExecDirect() add a call to SQLMoreResults() and check
the return code of SQLMoreResults(). That *should* work. You probably want
to call SQLMoreResults() in a loop until it returns SQL_ERROR or
SQL_NO_DATA.
BTW- ODBC does not use HRESULTS (as you are using below). ODBC uses the
SQLRETURN type. If your example, it just so happens that SQL_SUCCESS and
S_OK are both #define'd as ZERO.
There are only a few interesting error codes in ODBC:
0 SQL_SUCCESS
1 SQL_SUCCESS_WITH_INFO (should examine the diag records to see
what info was posted to the handle)
100 SQL_NO_DATA (no more results...)
-1 SQL_ERROR (generic error, need to examine the diag records to
see what error was posted to the handle).
The TRUE error codes in ODBC are stored as SQL States (in the diag records).
The ODBC reference material documents the different states and what they
mean (see Appendix A).
Brannon
[quoted text, click to view] "Ionut Ceausu" <shadow_s@softhome.net.NO_SPAM> wrote in message
news:uz1w%23YXmDHA.360@TK2MSFTNGP12.phx.gbl...
> Let's suppose we have an stored procedure that make an insert in a
> table. That insert fail (primary key constrain). This stored procedure is
> called from C using ODBC with
> hr = SQLExecuteDirect(hstmt,L"{call MyProc }",SQL_NTS)
>
> If the insert from MyProc fail, i will obtain an hr != S_OK (and from here
> with GetDiagRec I will obtain the error) only if in stored procedure I put
> SET NOCOUNT ON. How do I obtain the error without putting SET NOCOUNT ON?
I
> suppose this can be done (ADO can do this)
> Thanks.
>
>
>