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