SqlCommand Constructor(String,SqlConnection,SqlTransaction)
Initializes a new instance of the
SqlCommand class with the text of the query, a %% object, and the
SqlTransaction.
The following example creates a
SqlCommand and sets some of its properties.
public void CreateCommand()
{
SqlConnection myConnection = new SqlConnection(
"User Id=sa;Server=localhost;Initial Catalog=Test;");
myConnection.Open();
SqlTransaction myTrans = myConnection.BeginTransaction();
string mySelectQuery = "SELECT * FROM Test.Dept";
SqlCommand myCommand = new SqlCommand(mySelectQuery, myConnection,myTrans);
myCommand.FetchSize = 100
}
Public Sub CreateCommand()
Dim myConnection As New SqlConnection( _
"User Id=sa;Server=localhost;Initial Catalog=Test;")
myConnection.Open()
Dim myTrans As SqlTransaction = myConnection.BeginTransaction()
Dim mySelectQuery As String = _
"SELECT * FROM Test.Dept"
Dim myCommand As New SqlCommand(mySelectQuery, myConnection, myTrans)
myCommand.FetchSize = 100
End Sub