Public Sub ReadMyData(ByVal myConnString As String)
Dim dynamicsConnection As New DynamicsConnection(myConnString)
Dim dynamicsCommand As DynamicsCommand = dynamicsConnection.CreateCommand()
dynamicsCommand.CommandText = "SELECT contactid, firstname, lastname FROM contact"
dynamicsConnection.Open()
Dim dynamicsReader As DynamicsDataReader = dynamicsCommand.ExecuteReader()
Try
' Always call Read before accessing data.
While dynamicsReader.Read()
Console.WriteLine(String.Concat(dynamicsReader.GetGuid(0).ToString(), " ", _
dynamicsReader.GetString(1), " ", dynamicsReader.GetString(2)))
End While
Finally
' always call Close when done reading.
dynamicsReader.Close()
' Close the connection when done with it.
dynamicsConnection.Close()
End Try
End Sub