Delen via


DataCommand Class

Provides the ability to build and execute data commands of various types against data sources, and to retrieve read-only results or a command status code.

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.Data.Framework.DataSiteableObject<IVsDataConnection>
    Microsoft.VisualStudio.Data.Framework.DataCommand

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

Syntax

'Declaration
Public MustInherit Class DataCommand _
    Inherits DataSiteableObject(Of IVsDataConnection) _
    Implements IVsDataCommand
public abstract class DataCommand : DataSiteableObject<IVsDataConnection>, 
    IVsDataCommand
public ref class DataCommand abstract : public DataSiteableObject<IVsDataConnection^>, 
    IVsDataCommand
[<AbstractClass>]
type DataCommand =  
    class 
        inherit DataSiteableObject<IVsDataConnection>
        interface IVsDataCommand 
    end
public abstract class DataCommand extends DataSiteableObject<IVsDataConnection> implements IVsDataCommand

The DataCommand type exposes the following members.

Constructors

  Name Description
Protected method DataCommand() Initializes a new instance of the DataCommand class.
Protected method DataCommand(IVsDataConnection) Initializes a new instance of the DataCommand class together with a data connection object.

Top

Properties

  Name Description
Public property Site Gets or sets the object site. (Inherited from DataSiteableObject<T>.)

Top

Methods

  Name Description
Public method CreateParameter Creates a parameter object that can be passed into the DeriveSchema, DeriveSchema, Execute, or ExecuteWithoutResults methods on a DataCommand instance.
Public method DeriveParameters(String) Derives the parameters that can be specified for a given command.
Public method DeriveParameters(String, DataCommandType) Derives the parameters that can be specified for a given command.
Public method DeriveParameters(String, DataCommandType, Int32) Derives the parameters that can be specified for a given command.
Public method DeriveSchema(String) Derives the schema returned from a specified command. The schema indicates the layout of items and blocks in a data reader.
Public method DeriveSchema(String, DataCommandType) Derives the schema returned from a specified command. The schema indicates the layout of items and blocks in a data reader.
Public method DeriveSchema(String, DataCommandType, array<IVsDataParameter[]) Derives the schema returned from a specified command. The schema indicates the layout of items and blocks in a data reader.
Public method DeriveSchema(String, DataCommandType, array<IVsDataParameter[], Int32) Derives the schema returned from a specified command. The schema indicates the layout of items and blocks in a data reader.
Public method Equals Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public method Execute(String) Executes a specified command and returns read-only results.
Public method Execute(String, DataCommandType) Executes a specified command and returns read-only results.
Public method Execute(String, DataCommandType, array<IVsDataParameter[]) Executes a specified command, optionally with parameters, and returns read-only results.
Public method Execute(String, DataCommandType, array<IVsDataParameter[], Int32) Executes a specified command, optionally with parameters, and returns read-only results.
Public method ExecuteWithoutResults(String) Executes a command but does not request results, instead returning an integer indicating the outcome of the call.
Public method ExecuteWithoutResults(String, DataCommandType) Executes a command but does not request results, instead returning an integer indicating the outcome of the call.
Public method ExecuteWithoutResults(String, DataCommandType, array<IVsDataParameter[]) Executes a command, optionally with parameters, but does not request results, instead returning an integer indicating the outcome of the call.
Public method ExecuteWithoutResults(String, DataCommandType, array<IVsDataParameter[], Int32) Executes a command, optionally with parameters, but does not request results, instead returning an integer indicating the outcome of the call.
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as the default hash function. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method OnSiteChanged Raises the SiteChanged event. (Inherited from DataSiteableObject<T>.)
Public method Prepare(String) Prepares the specified command on the data source to be executed; the command can then be executed multiple times, with varying parameters.
Public method Prepare(String, DataCommandType) Prepares the specified command on the data source to be executed; the command can then be executed multiple times, with varying parameters.
Public method Prepare(String, DataCommandType, array<IVsDataParameter[]) Prepares the specified command on the data source to be executed; the command can then be executed multiple times, with varying parameters.
Public method Prepare(String, DataCommandType, array<IVsDataParameter[], Int32) Prepares the specified command on the data source to be executed; the command can then be executed multiple times, with varying parameters.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Events

  Name Description
Public event SiteChanged Occurs when the Site property is changed. (Inherited from DataSiteableObject<T>.)

Top

Remarks

Data Designer Extensibility (DDEX) providers can execute various types of commands against a data source. This may include, but is not limited to, SQL statements, procedures, and function calls. They may also expose the ability to prepare and derive parameters and schemas for commands.

The DataCommand class introduces command types. A command type indicates a programmatic interpretation of a given command string. For example, a command type Text might notify the DDEX provider that the command string is a SQL statement that should be executed directly. Alternatively, a TabularFunction command type might notify the DDEX provider that the command string is the name of a table-valued function that should be executed by using the appropriate method.

Underlying technologies such as Open Database Connectivity (ODBC), OLE DB, and ADO.NET attempt to enumerate a set of allowed command types, typically as plain text, in table form, or as stored procedures. The DataCommand class extends this concept by relaxing the requirement that such a command type originate in a fixed enumeration. This provides flexibility by enabling DDEX providers to add custom command types, along with descriptions of how and when the commands can be used.

Note

To provide command execution capability asynchronously, use the DataAsyncCommand class. This class has a set of methods that are equivalent to those on the DataCommand class, but these methods operate asynchronously.

Notes to Inheritors

When you inherit from the DataCommand class, you must override each method from this class that is to be supported by its DDEX provider implementation. The base implementation of each method in this class throws a NotSupportedException.

Note that the ExecuteWithoutResults method has a base implementation that delegates to the Execute method.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.VisualStudio.Data.Framework Namespace

DataCommandType