dotConnect for Dynamics 365 Documentation
Devart.Data.Dynamics Namespace / DynamicsCommand Class / ExecuteReader Method / ExecuteReader(CommandBehavior) Method
One of the System.Data.CommandBehavior values.
Example

ExecuteReader(CommandBehavior) Method
Sends the CommandText to the Connection, and builds a DynamicsDataReader using one of the System.Data.CommandBehavior values.
Syntax
'Declaration
 
Public Overloads Shadows Function ExecuteReader( _
   ByVal behavior As CommandBehavior _
) As DynamicsDataReader
 

Parameters

behavior
One of the System.Data.CommandBehavior values.

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. 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
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