CommandType
CommandTypecommandType
= Command.CommandType; Command.CommandType =commandType
;
Indicates how the CommandText
property should be
interpreted, using the values from the
System.Data.CommandType
enumeration. Table 19-2 lists possible values.
The following code snippet configures a Command
object to call a stored procedure called
GetCustomers
. The CommandText
and Connection
properties are set using a
Command
constructor.
SqlCommand cmd = new SqlCommand("GetCustomers", con); cmd.CommandText = CommandType.StoredProcedure;
TableDirect
isn’t supported by
all providers and isn’t suitable for an
enterprise-level application because it returns all the information
from all the rows of a table. This wastes bandwidth and server time
retrieving information that may not be important. A much better
approach is to selectively limit the rows you return with a WHERE
clause and the columns of information you need. Ideally, database
access should be performed through a stored procedure, which can be
precompiled and optimized on the database server.