3.5. Commands

Data providers implement a Command class, such as SqlCommand or OleDbCommand, to execute action statements and submit queries to the database. This class must implement the IDbCommand interface. You can create the Command instance from a Connection instance using the IDbConnection.CreateCommand method. You can also instantiate it directly using a variety of constructors.

The constructor can specify a command string, or you can set the command string by using the CommandText property. The most useful constructor overloads accept an instance of the correct subclass of Connection. The Connection does not have to be open in order to be used in the Command object's constructor. Note that there is not a constructor that takes a command ...

Get Essential ADO.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.