Export (0) Print
Expand All

IDbCommand Interface

Represents an SQL statement that is executed while connected to a data source, and is implemented by .NET Framework data providers that access relational databases.

Namespace: System.Data
Assembly: System.Data (in system.data.dll)

public interface class IDbCommand : IDisposable
public interface IDbCommand extends IDisposable
public interface IDbCommand extends IDisposable

The IDbCommand interface enables an inheriting class to implement a Command class, which represents an SQL statement that is executed at a data source. For more information about Command classes, see Executing a Command. For more information about implementing .NET Framework data providers, see Implementing a .NET Framework Data Provider.

An application does not create an instance of the IDbCommand interface directly, but creates an instance of a class that inherits IDbCommand.

Classes that inherit IDbCommand must implement all inherited members, and typically define additional members to add provider-specific functionality. For example, the IDbCommand interface defines the ExecuteNonQuery method. In turn, the SqlCommand class inherits this method, and also defines the ExecuteXmlReader method.

Notes to Implementers To promote consistency among .NET Framework data providers, name the inheriting class in the form PrvClassname where Prv is the uniform prefix given to all classes in a specific .NET Framework data provider namespace. For example, Sql is the prefix of the SqlCommand class in the System.Data.SqlClient namespace. When you inherit from the IDbCommand interface, you should implement the following constructors:

Item

Description

PrvCommand()

Initializes a new instance of the PrvCommand class.

PrvCommand(string cmdText)

Initializes a new instance of the PrvCommand class with the text of the query.

PrvCommand(string cmdText, PrvConnection connection)

Initializes a new instance of the PrvCommand class with the text of the query and a PrvConnection.

PrvCommand(string cmdText, PrvConnection connection, PrvTransaction transaction)

Initializes a new instance of the PrvCommand class with the text of the query, a PrvConnection, and the PrvTransaction.

The following example creates instances of the derived classes, SqlConnection, SqlCommand, and SqlDataReader. The example reads through the data, writing it to the console. Finally, the example closes the SqlDataReader, then the SqlConnection.

No code example is currently available or this language may not be supported.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft