CommandType (overridden)

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


VB.NET

Public Overrides Property CommandType As CommandType

C#
public override CommandType CommandType { get; set; }


Gets or sets a value indicating how the
CommandText property is to be interpreted.

Values
StoredProcedure : The name of a stored procedure.
TableDirect : The name of a table.
Text : An SQL text command. (Default.)

When the
CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure to be accessed. The user may be required to use escape character syntax or include qualifying characters if any of the specified tables named contain any special characters. All rows and columns of the named table or tables will be returned when you call one of the Execute methods of a Command object.

When the
CommandType property is set to TableDirect, the CommandText property should be set to the name of the table to be accessed. The user may be required to use escape character syntax or include qualifying characters if any of the tables named contain any special characters. All rows and columns of the named table will be returned when you call one of the Execute methods.

In order to access multiple tables, use a comma delimited list, without spaces or padding, containing the names of the tables to access. When the
CommandText property names multiple tables, a join of the specified tables is returned.

Exceptions
ArgumentException: The value was not a valid CommandType