System.Data.SqlClient Namespace SqlCommand Class
Initializes a new instance of the SqlCommand class with the text of the query.
[ VB ]
Public Sub New ( _
ByVal cmdText As String _
)
[ C# ]
public SqlCommand (
string cmdText
);
[ C++ ]
public: SqlCommand (
String* cmdText
);
[ JScript ]
public function SqlCommand (
cmdText : String
);
- cmdText
- The text of the query.
The following table shows initial property values for an instance of SqlCommand created with this constructor.
You can change the value for any of these properties through a separate call to the property.
The following example initializes an SqlCommand using this constructor and sets some of its properties.
void setSqlCommand ( ) {
string query = "SELECT * FROM Categories ORDER BY CategoryID";
SqlCommand myCommand = new SqlCommand ( query );
myCommand.CommandTimeout = 15;
myCommand.CommandType = CommandType.Text;
}
Public Sub setSqlCommand ( )
Dim query As String = "SELECT * FROM Categories ORDER BY CategoryID"
Dim myCommand As New SqlCommand ( query )
myCommand.CommandTimeout = 15
myCommand.CommandType = CommandType.Text
End Sub |
|
C# |
VB |
SqlCommand Members SqlCommand Constructor Overload List