dotConnect for Dynamics 365 Documentation
Devart.Data.Dynamics Namespace / DynamicsCommand Class / ExecuteReader Method / ExecuteReader() Method
Example

ExecuteReader() Method
Sends the CommandText to the Connection and builds a DynamicsDataReader.
Syntax
'Declaration
 
Public Overloads Shadows Function ExecuteReader() As DynamicsDataReader
 

Return Value

Example
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.
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();
  try
  {
    while(dynamicsReader.Read())
    {
      Console.WriteLine(dynamicsReader.GetString(0));
    }
  }
  finally
  {
    dynamicsReader.Close();
    dynamicsConnection.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()
  Try
    While dynamicsReader.Read()
      Console.WriteLine(dynamicsReader.GetString(0))
    End While
  Finally
    dynamicsReader.Close()
    dynamicsConnection.Close()
  End Try
End Sub
Requirements

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

See Also