Freigeben über


ExecuteWithResultsAndMessages Method

Diese Funktion wird in zukünftigen Versionen von Microsoft SQL Server nicht mehr bereitgestellt. Verwenden Sie diese Funktion beim Entwickeln neuer Anwendungen nicht, und planen Sie das Ändern von Anwendungen, in denen es zurzeit verwendet wird.

The ExecuteWithResultsAndMessages method executes a Transact-SQL command batch returning batch result sets in a QueryResults object and capturing messages raised as part of command batch execution.

Syntax

object
.ExecuteWithResultsAndMessages(
Command 
,
Length
,
Messages
)
as
QueryResults

Parts

  • object
    Expression that evaluates to an object in the Applies To list.

  • Command
    String that specifies a Transact-SQL or provider-specific command batch.

  • Length
    Long integer that indicates the statement batch length.

  • Messages
    String used to return message output.

Prototype (C/C++)

HRESULT ExecuteWithResultsAndMessages(
SQLDMO_LPCSTR Command,
LPSQLDMOQUERYRESULTS* ppResults,
SQLDMO_LPBSTR Messages,
long lLength);
HinweisHinweis

SQL Distributed Management Objects (SQL-DMO) strings are always returned as OLE BSTR objects. A C/C++ application obtains a reference to the string. The application must release the reference using SysFreeString.

Returns

A QueryResults object that contains command batch results. The method fills the string specified by the Messages argument with message returns, if any are generated by batch execution.

Hinweise

The ExecuteWithResultsAndMessages2 method extends the functionality of the ExecuteWithResultsAndMessages method.

Visual Basic applications should call ExecuteWithResultsAndMessages2 instead of ExecuteWithResultsAndMessages. ExecuteWithResultsAndMessages2 is not available to C++ applications, which should call ExecuteWithResultsAndMessages.

For Microsoft SQL Server error severity indicates the degree of an error condition. Some errors are severe enough to terminate statement execution prematurely. Any error with a severity of 10 or higher is returned to the SQL-DMO application through normal error handling.

Minor errors, SQL Server errors with a severity of less than 10, indicate that statement execution succeeded, but that success was conditional. These are called Success-with-information errors. Some Transact-SQL statements, such as the PRINT statement, do not generate result sets, using messages for their return value.

The ExecuteWithResultsAndMessages2 method implements command batch execution for a SQL Distributed Management Objects (SQL-DMO) application, allowing the application to capture success-with-information errors or other information transmitted as messages.

HinweisHinweis

When using the ExecuteWithResultsAndMessages method with the LinkedServer object, command batch syntax is provider-specified. Some OLE DB providers may support message returns as defined for SQL Server. For more information, see the OLE DB provider documentation.