ExecuteReader(CommandBehavior) Method
The following example creates a
DynamicsCommand, then executes it by passing a string that is SQL SELECT statement, and a string to use to connect to the data source. The
System.Data.CommandBehavior is then set to CloseConnection.
public void CreateDynamicsDataReader(string mySelectQuery,string dynamicsConnectionString)
{
DynamicsConnection dynamicsConnection = new DynamicsConnection(dynamicsConnectionString);
DynamicsCommand dynamicsCommand = new DynamicsCommand(mySelectQuery, dynamicsConnection);
dynamicsCommand.Connection.Open();
DynamicsDataReader dynamicsReader = dynamicsCommand.ExecuteReader(CommandBehavior.CloseConnection);
while(dynamicsReader.Read())
{
Console.WriteLine(dynamicsReader.GetString(0));
}
dynamicsReader.Close();
}
Public Sub CreateDynamicsDataReader(mySelectQuery As String, _
dynamicsConnectionString As String)
Dim dynamicsConnection As New DynamicsConnection(dynamicsConnectionString)
Dim dynamicsCommand As New DynamicsCommand(mySelectQuery, dynamicsConnection)
dynamicsCommand.Connection.Open()
Dim dynamicsReader As DynamicsDataReader = dynamicsCommand.ExecuteReader(CommandBehavior.CloseConnection)
While dynamicsReader.Read()
Console.WriteLine(dynamicsReader.GetString(0))
End While
dynamicsReader.Close()
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