asp.net.ph

SqlCommand Constructor

System.Data.SqlClient Namespace   SqlCommand Class


Initializes a new instance of the SqlCommand class.

Overload List

1. Initializes a new instance of the SqlCommand class.

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

3. Initializes a new instance of the SqlCommand class with the text of the query and an SqlConnection.

4. Initializes a new instance of the SqlCommand class with the text of the query, an SqlConnection, and the SqlTransaction.


Example

The following example initializes an SqlCommand and sets some of its properties.

NOTE: This example uses one of the overloaded versions of the SqlCommand constructor. For other examples that may be available, see the individual overload topics.

void setSqlCommand ( ) {
   SqlConnection myConn = new SqlConnection (
      "uid=sa; pwd=; initial catalog=northwind; data source=myServer" );
   myConn.Open ( );
   SqlTransaction myTrans = myConn.BeginTransaction ( );
   string query = "SELECT * FROM Categories ORDER BY CategoryID";
   SqlCommand myCommand = new SqlCommand ( query, myConn,myTrans );
}
  C# VB

See Also

SqlCommand Members Skip Navigation Links




Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note