System.Data 1.0.5000.0 2.0.0.0 System.Data.Common.DbCommand System.ICloneable System.ComponentModel.DefaultEvent("RecordsAffected") System.ComponentModel.ToolboxItem("System.Drawing.Design.ToolboxItem, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") System.ComponentModel.Designer("Microsoft.VSDesigner.Data.VS.OdbcCommandDesigner, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")

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

Item

Description

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 property and reuse the object. However, you must close the before you can execute a new or previous command.

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

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

- Constructor

  The base constructor initializes all fields to their default values. The following table shows initial property values for an instance of .

  Properties

  Initial Value

  empty string ("")

  30

  Text

  null

  Initializes a new instance of the class.

  1.0.5000.0
  2.0.0.0
- Constructor
  To be added.

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

  The text of the query.
  1.0.5000.0
  2.0.0.0
- Constructor
  To be added.

  Initializes a new instance of the class with the text of the query and an object.

  The text of the query.
  An object that represents the connection to a data source.
  1.0.5000.0
  2.0.0.0
- Constructor

  The following table shows initial property values for an instance of this implementation of the .

  Properties

  Initial Value

  30

  Text

  A new that is the value for the parameter.

  You can change the value for any one of these parameters by setting the related property.

  Initializes a new instance of the class with the text of the query, an object, and the .

  The text of the query.
  An object that represents the connection to a data source.
  The transaction in which the executes.
  1.0.5000.0
  2.0.0.0
- Method
  System.Void

  If there is nothing to cancel, nothing occurs. However, if there is a command in process, and the cancellation try fails, no exception is generated.

  To cancel a query on one thread, must be called from another thread. Because you cannot execute commands asynchronously with , to cancel a command from another thread, one thread must be running synchronously. This means that the object must be accessible from both threads.

  Tries to cancel the execution of an .

  1.0.5000.0
  2.0.0.0
- Property
  System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.All)
  System.ComponentModel.Editor("Microsoft.VSDesigner.Data.Odbc.Design.OdbcCommandTextEditor, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
  System.ComponentModel.DefaultValue("")
  System.String To be added.

  When the property is set to StoredProcedure, the property should be set using standard ODBC stored procedure escape sequences. Setting the to the name of the stored procedure does not function as it does for other .NET Framework data providers.

  Many language features, such as outer joins and scalar function calls, are generally implemented by data sources. Even the syntax for these features is generally data source-specific. Therefore, ODBC defines escape sequences that contain standard syntax for the following language features:

  Date, time, timestamp, and datetime interval literals

  Scalar functions such as numeric, string, and data type conversion functions

  LIKE predicate escape character

  Outer joins

  Procedure calls

  The escape sequence used by ODBC is as follows:

  `{extension}`

  This escape sequence is recognized and parsed by ODBC drivers. They then replace any escape sequences with data source-specific grammar.

  A procedure is an executable object stored at the data source. Generally, it is one or more SQL statements that have been precompiled. The escape sequence for calling a procedure is

  `{[?=]call procedure-name[([parameter][,[parameter]]...)]}`

  where specifies the name of a procedure and specifies a procedure parameter.

  The command executes this stored procedure when you call one of the Execute methods (for example, or ).

  You cannot set the , and properties if the current connection is performing an execute or fetch operation.

  The ODBC.NET Provider does not support named parameters for passing parameters to an SQL statement or a stored procedure called by an when is set to Text. In this case, the question mark (?) placeholder must be used. For example:

  `SELECT * FROM Customers WHERE CustomerID = ?`

  Therefore, the order in which objects are added to the must directly correspond to the position of the question mark placeholder for the parameter.

  If a parameter contains a null value, the .NET Framework Data Provider for ODBC still binds that parameter, but uses a default parameter, if one has been defined by using SQL_DEFAULT_PARAM, instead of the null value. For example, the :

  `{1, null, 2}`

  passed into the property:

  `{call sp(?, ?, ?)}`

  causes the .NET Framework Data Provider for ODBC binding the first parameter to the value 1, the third parameter to the value 2, and the second parameter as SQL_DEFAULT_PARAM. However, this behavior is driver-dependent. If the driver does not support this functionality, just do not pass in a value for the parameter. For example, use the :

  `{1, 2}`

  and set the property to the following:

  `{call sp(?, null, ?)}`

  If a parameter is omitted, the comma delimiting it from other parameters must still appear. If an input or input/output parameter is omitted, the procedure uses the default value of the parameter. Another way to specify the default value of an input or input/output parameter is to set the value of the length/indicator buffer bound to the parameter to SQL_DEFAULT_PARAM.

  Gets or sets the SQL statement or stored procedure to execute against the data source.

  1.0.5000.0
  2.0.0.0
- Property
  System.Int32 To be added.

  A value of zero (0) specifies no limit to the wait time, instead of no wait time, and therefore should be avoided.

  Gets or sets the wait time before terminating an attempt to execute a command and generating an error.

  1.0.5000.0
  2.0.0.0
- Property
  System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.All)
  System.ComponentModel.DefaultValue("Text")
  System.Data.CommandType To be added.

  When the property is set to StoredProcedure, you should set the property to the full ODBC call syntax. The command then executes this stored procedure when you call one of the Execute methods (for example, or ).

  The , and properties cannot be set if the current connection is performing an execute or fetch operation.

  The .NET Framework Data Provider for ODBC does not support passing named parameters to an SQL statement or to a stored procedure called by an . In either of these cases, use the question mark (?) placeholder. For example:

  `SELECT * FROM Customers WHERE CustomerID = ?`

  The order in which objects are added to the must directly correspond to the position of the question mark placeholder for the parameter.

  The .NET Framework Data Provider for ODBC does not support the setting of TableDirect.

  Gets or sets a value that indicates how the property is interpreted.

  1.0.5000.0
  2.0.0.0
- Property
  System.Data.Odbc.OdbcConnection To be added.

  You cannot set the , , and properties if the current connection is performing an execute or fetch operation.

  If you set while a transaction is in progress and the property is not null, an is generated. If you set after the transaction has been committed or rolled back, and the property is not null, the property is then set to a null value.

  Gets or sets the used by this instance of the .

  1.0.5000.0
  2.0.0.0
  System.ComponentModel.Editor("Microsoft.VSDesigner.Data.Design.DbConnectionEditor, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
  System.ComponentModel.DefaultValue(null)
- Method
  System.Data.Common.DbParameter To be added. To be added. To be added. 2.0.0.0
- Method
  System.Data.Odbc.OdbcParameter

  The method is a strongly-typed version of .

  Creates a new instance of an object.

  An object.

  1.0.5000.0
  2.0.0.0
- Property
  System.Data.Common.DbConnection To be added. To be added. To be added. 2.0.0.0
- Property
  System.Data.Common.DbParameterCollection To be added. To be added. To be added. 2.0.0.0
- Property
  System.Data.Common.DbTransaction To be added. To be added. To be added. 2.0.0.0
- Property
  System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)
  System.ComponentModel.DefaultValue(true)
  System.ComponentModel.DesignOnly(true)
  System.ComponentModel.Browsable(false)
  System.Boolean To be added. To be added.

  Gets or sets a value that indicates whether the command object should be visible in a customized interface control.

  1.0.5000.0
  2.0.0.0
- Method
  System.Void `` To be added. To be added. To be added. 1.0.5000.0 2.0.0.0
- Method
  System.Data.Common.DbDataReader `` To be added. To be added. To be added. To be added. 2.0.0.0
- Method
  System.Int32

  You can use to perform catalog operations (for example, querying the structure of a database or creating database objects such as tables); or to change the data in a database, without using a , by executing UPDATE, INSERT, or DELETE statements.

  You can also use to execute multiple SQL statements if the underlying ODBC driver supports this functionality. In this case, the return value is the number of rows affected by all statements in the command.

  Although returns no rows, any output parameters or return values mapped to parameters are populated with data.

  For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.

  When a trigger exists on a table and data is being added or changed in the table, the return value includes the number of rows affected by both the insert or update operation and the number of rows affected by the trigger or triggers.

  Executes an SQL statement against the and returns the number of rows affected.

  For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1.

  1.0.5000.0
  2.0.0.0
- Method
  System.Data.Odbc.OdbcDataReader

  You should set the property to the full ODBC call syntax for stored procedures. The command executes this stored procedure when you call .

  While the is used, the associated is busy serving the . While in this state, no other operations can be performed on the other than closing it. This is the case until the method of the is called.

  Sends the to the and builds an .

  An object.

  1.0.5000.0
  2.0.0.0
- Method
  System.Data.Odbc.OdbcDataReader ``

  If you expect your SQL statement to return only a single row, specifying SingleRow as the value may improve application performance.

  You should set the property to the full ODBC call syntax for stored procedures. The command executes this stored procedure when you call .

  The supports a special mode that enables large binary values to be read efficiently. For more information, see the SequentialAccess setting for .

  The SequentialAccess value of is not a limiting setting; it just means that you will have at least sequential access to the . For example, when you use the SQL Server ODBC Driver in SequentialAccess mode, you can still move to the first column of an row after having read through all the other columns sequentially.

  While the is used, the associated is busy serving the . While in this state, no other operations can be performed on the other than closing it. This is the case until you call the method. If the is created with set to CloseConnection, closing the closes the connection automatically.

  Sends the to the , and builds an using one of the CommandBehavior values.

  An object.

  One of the System.Data.CommandBehavior values. 1.0.5000.0 2.0.0.0
- Method
  System.Object

  Use the method to retrieve a single value (for example, an aggregate value) from a data source. This requires less code than using the method, and then performing the operations required to generate the single value from the data returned by an .

  Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.

  The first column of the first row in the result set, or a null reference if the result set is empty.

  1.0.5000.0
  2.0.0.0
- Property
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
  System.Data.Odbc.OdbcParameterCollection To be added.

  When is set to Text, the .NET Framework Data Provider for ODBC does not support passing named parameters to an SQL statement or to a stored procedure called by an . In either of these cases, use the question mark (?) placeholder. For example:

  `SELECT * FROM Customers WHERE CustomerID = ?`

  The order in which objects are added to the must directly correspond to the position of the question mark placeholder for the parameter in the command text.

  If the parameters in the collection do not match the requirements of the query to be executed, an error may result.

  Gets the .

  1.0.5000.0
  2.0.0.0
- Method
  System.Void

  The method calls the ODBC SQLPrepare function. Depending on the capabilities of the underlying ODBC driver and data source, parameter information such as data types may be checked when the statement is prepared, if all parameters have been bound, or when it is executed if not all parameters have been bound. For maximum interoperability, an application should unbind all parameters that applied to a previous SQL statement before preparing a new SQL statement on the same . This prevents errors that are caused by previous parameter information being applied to the new SQL statement.

  If you call an Execute method after you call , any parameter value that is larger than the value specified by the property is automatically truncated to the original specified size of the parameter, and no truncation errors are returned.

  Output parameters (whether prepared or not) must have a user-specified data type. If you specify a variable length data type, you must also specify the maximum .

  Creates a prepared or compiled version of the command at the data source.

  1.0.5000.0
  2.0.0.0
- Method
  System.Void

  The default value of the is 30 seconds.

  Resets the property to the default value.

  1.0.5000.0
  2.0.0.0
- Property
  1.0.5000.0
  2.0.0.0
  System.Data.IDbConnection To be added. To be added. To be added.
- Method
  1.0.5000.0
  System.Data.IDbDataParameter To be added. To be added. To be added.
- Method
  1.0.5000.0
  System.Data.IDataReader To be added. To be added. To be added.
- Method
  1.0.5000.0
  System.Data.IDataReader `` To be added. To be added. To be added. To be added.
- Property
  1.0.5000.0
  2.0.0.0
  System.Data.IDataParameterCollection To be added. To be added. To be added.
- Property
  1.0.5000.0
  2.0.0.0
  System.Data.IDbTransaction To be added. To be added. To be added.
- Method
  1.0.5000.0
  2.0.0.0
  System.Object

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface.

  For a description of this member, see .

  A new that is a copy of this instance.

- Property
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.ComponentModel.Browsable(false)
  System.Data.Odbc.OdbcTransaction To be added.

  You cannot set the property if it is already set to a specific value, and the command is in the process of executing. If you set the transaction property to an object that is not connected to the same as the object, an exception will be thrown the next time that you try to execute a statement.

  Gets or sets the within which the executes.

  1.0.5000.0
  2.0.0.0
- Property
  System.ComponentModel.DefaultValue(System.Data.UpdateRowSource.Both)
  System.Data.UpdateRowSource To be added.

  The default value is Both unless the command is automatically generated, as with the , in which case the default is None.

  For more information about how to use the property, see Using Parameters with a DataAdapter.

  Gets or sets a value that specifies how the Update method should apply command results to the DataRow.

  1.0.5000.0
  2.0.0.0