Command object can be divided into 4 kinds, Sqlcommand,oledbcomman,olbccommand,oraclecomman
Property
|
Description |
CommandType |
Gets or sets the type of command object to execute |
CommandText |
Gets or sets the SQL statement or stored procedure name or table name to be executed against the data source |
CommandTimeout |
Gets or sets the wait time before terminating an attempt to execute a command and generating an error |
Connection |
Gets or sets the name of the connection object used by the Command object |
Parameters |
Gets the parameter collection that the command object needs to use |
CommandType enumeration members
Member name |
Description |
Text |
SQL Text Command |
StoredProcedure |
Name of the stored procedure |
TableDirect |
Name of the table |
Common methods of SqlCommand
Method |
Description |
ExecuteNonQuery |
Used to execute non-select commands, such as Insert,delete,update, to return the number of rows affected, or to create new, update, and delete database objects |
ExecuteScalar |
Used to execute a SELECT query command that returns the value of the first column in the first row of data, which is typically used to execute a SELECT command that uses the count or Sum function |
ExecuteReader |
Executes the SELECT command and returns a DataReader object that is a read-only forward data set |