Partager via


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

'Declaration
Public Overridable Function Execute ( _
    command As String, _
    commandType As Integer, _
    parameters As DataParameter(), _
    commandTimeout As Integer _
) As DataReader
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
)
abstract Execute : 
        command:string * 
        commandType:int * 
        parameters:DataParameter[] * 
        commandTimeout:int -> DataReader  
override Execute : 
        command:string * 
        commandType:int * 
        parameters:DataParameter[] * 
        commandTimeout:int -> DataReader
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.

  • 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.

Note

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

.NET Framework Security

See Also

Reference

DataCommand Class

Microsoft.VisualStudio.Data Namespace

DataCommandType

ExecuteWithoutResults