DataCommand.Execute Method

Executes a specified command, optionally with parameters, and returns read-only results.

Namespace:  Microsoft.VisualStudio.Data
Assembly:  Microsoft.VisualStudio.Data (in Microsoft.VisualStudio.Data.dll)

Syntax

'宣言
Public Overridable Function Execute ( _
    command As String, _
    commandType As Integer, _
    parameters As DataParameter(), _
    commandTimeout As Integer _
) As DataReader
'使用
Dim instance As DataCommand
Dim command As String
Dim commandType As Integer
Dim parameters As DataParameter()
Dim commandTimeout As Integer
Dim returnValue As DataReader

returnValue = instance.Execute(command, _
    commandType, parameters, commandTimeout)
public virtual DataReader Execute(
    string command,
    int commandType,
    DataParameter[] parameters,
    int commandTimeout
)
public:
virtual DataReader^ Execute(
    String^ command, 
    int commandType, 
    array<DataParameter^>^ parameters, 
    int commandTimeout
)
public function Execute(
    command : String, 
    commandType : int, 
    parameters : DataParameter[], 
    commandTimeout : int
) : DataReader

Parameters

  • command
    Type: System.String

    A command to execute that is specific to a data source.

  • commandType
    Type: System.Int32

    The command type for the indicated command, specifying how to interpret the contents of the command parameter.

  • parameters
    Type: []

    An array of DataParameter objects for the specified command type. While this is an input parameter, the DDEX provider is still able to set properties on individual out and return value parameters.

  • commandTimeout
    Type: System.Int32

    The length of time, in seconds, to block the client before canceling the execution and returning to the caller. A value of 0 indicates infinite timeout; a value of -1 indicates a provider default.

Return Value

Type: Microsoft.VisualStudio.Data.DataReader

Returns a DataReader object, which provides a forward-only, read-only stream from the data source.

Exceptions

Exception Condition
ArgumentNullException

The command or asyncCommandEvents are null.

ArgumentException

The commandType specifies an invalid type.

ArgumentOutOfRangeException

The commandTimeout is less than -1.

NotSupportedException

The provider does not support this method.

Remarks

Due to varying orders in which data and parameter values can be returned by a data source, any out or return value parameters specified in the parameters array of DataParameter objects can be retrieved only after the returned DataReader has been closed.

注意

Other exceptions that occur indicate that the parameter derivation failed for a provider-specified reason.

Permissions

See Also

Reference

DataCommand Class

DataCommand Members

Microsoft.VisualStudio.Data Namespace

DataCommandType

ExecuteWithoutResults