'Declaration Public Shadows Property Connection As SqlConnection
public new SqlConnection Connection {get; set;}
'Declaration Public Shadows Property Connection As SqlConnection
public new SqlConnection Connection {get; set;}
SqlConnection specified in this property will carry out all operations executed with this SqlCommand.
This property supports the InterForm technology.
A single SqlConnection can be used by many SqlCommand objects on the assumption that all operations will be done consecutively. In other words, you can not execute an SQL statement while an asynchronous operation is in progress.
public void CreateCommand() { string mySelectQuery = "SELECT * FROM Test.Dept ORDER BY DeptNo"; SqlCommand myCommand = new SqlCommand(mySelectQuery); myCommand.Connection = new SqlConnection( "User Id=sa;Server=localhost;Initial Catalog=Test;"); myCommand.CommandType = System.Data.CommandType.Text; }
Public Sub CreateCommand() Dim mySelectQuery As String = _ "SELECT * FROM Test.Dept ORDER BY DeptNo" Dim myCommand As New SqlCommand(mySelectQuery) myCommand.Connection = New SqlConnection( _ "User Id=sa;Server=localhost;Initial Catalog=Test;") myCommand.CommandType = System.Data.CommandType.Text End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2