OdbcCommand Class

Represents an SQL statement or stored procedure to execute against a data source. This class cannot be inherited.

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

public ref class OdbcCommand sealed : public DbCommand, ICloneable
public final class OdbcCommand extends DbCommand implements ICloneable
public final class OdbcCommand extends DbCommand implements ICloneable

The OdbcCommand class provides the following methods for executing commands against a data source:




Executes commands that return rows.


Executes commands such as SQL INSERT, DELETE, UPDATE, and SET statements.


Retrieves a single value, for example, an aggregate value, from a database.

You can reset the CommandText property and reuse the OdbcCommand object. However, you must close the OdbcDataReader before you can execute a new or previous command.

If execution of the command causes a fatal OdbcException such as a SQL Server severity level of 20 or more, OdbcConnection may close. However, the user can reopen the connection and continue.

The following example uses the ExecuteReader method of the OdbcCommand class, together with the OdbcDataReader and OdbcConnection classes, to select rows from a table.

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

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

Windows 98, Windows 2000 SP4, Windows Millennium Edition, 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