Condividi tramite


How to: Process Return Codes and Output Parameters (ODBC)

Data creazione: 14 aprile 2006

SQL Server stored procedures can have integer return codes and output parameters. The return codes and output parameters are sent in the last packet from the server and are not available to the application until SQLMoreResults returns SQL_NO_DATA.

For a sample showing how to process a return code and output parameter, see ProcessReturnCodes.cpp, which you can download from the SQL Server Downloads page on MSDN. This sample was developed using Microsoft Visual C++ 2005 and was developed for ODBC version 3.0 or later.

ms403283.security(it-it,SQL.90).gifNota sulla protezione:
When possible, use Windows Authentication. If Windows Authentication is not available, prompt users to enter their credentials at run time. Avoid storing credentials in a file. If you must persist credentials, you should encrypt them with the Win32 crypto API.

To process return codes and output parameters

  1. Construct an SQL statement that uses the ODBC CALL escape sequence. The statement should use parameter markers for each input, input/output, and output parameter, and for the procedure return value (if any).

  2. Call SQLBindParameter for each input, input/output, and output parameter, and for the procedure return value (if any).

  3. Execute the statement with SQLExecDirect.

  4. Process result sets until SQLFetch or SQLFetchScroll returns SQL_NO_DATA while processing the last result set or until SQLMoreResults returns SQL_NO_DATA. At this point, the variables bound to the return code and output parameters are filled with returned data values.

Vedere anche

Altre risorse

Running Stored Procedures (ODBC)

Guida in linea e informazioni

Assistenza su SQL Server 2005