Represents an open connection to a cloud application.
The following sample demonstrates how using base classes helps to create data source-independent code.
public void PrintData(SqlShimConnection myConnection) {
SqlShimCommand myCommand = (SqlShimCommand)myConnection.CreateCommand();
myCommand.CommandText = "SELECT contactid, firstname, lastname FROM contact";
myConnection.Open();
SqlShimDataReader myReader = myCommand.ExecuteReader();
try {
while (myReader.Read()) {
Console.WriteLine(myReader.GetGuid(0).ToString() + " " +
myReader.GetString(1) + " " + myReader.GetString(2));
}
}
finally {
myReader.Close();
myConnection.Close();
}
}
Public Sub PrintData(ByVal myConnection As SqlShimConnection)
Dim myCommand As SqlShimCommand = myConnection.CreateCommand()
myCommand.CommandText = "SELECT contactid, firstname, lastname FROM contact"
myConnection.Open()
Dim myReader As SqlShimDataReader = myCommand.ExecuteReader()
Try
While myReader.Read()
Console.WriteLine(String.Concat(myReader.GetGuid(0).ToString(), " ", _
myReader.GetString(1), " ", myReader.GetString(2)))
End While
Finally
myReader.Close()
myConnection.Close()
End Try
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