dotConnect for SugarCRM Documentation
Devart.Data.Sugar Namespace / SugarCommand 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 SugarDataReader using one of the System.Data.CommandBehavior values.
Syntax
'Declaration
 
Public Overloads Shadows Function ExecuteReader( _
   ByVal behavior As CommandBehavior _
) As SugarDataReader
 

Parameters

behavior
One of the System.Data.CommandBehavior values.

Return Value

A SugarDataReader object.
Example
The following example creates a SugarCommand, 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 CreateSugarDataReader(string mySelectQuery,string sugarConnectionString)
{
  SugarConnection sugarConnection = new SugarConnection(sugarConnectionString);
  SugarCommand sugarCommand = new SugarCommand(mySelectQuery, sugarConnection);
  sugarCommand.Connection.Open();
  SugarDataReader sugarReader = sugarCommand.ExecuteReader(CommandBehavior.CloseConnection);
  while(sugarReader.Read())
  {
    Console.WriteLine(sugarReader.GetString(0));
  }
  sugarReader.Close();
}
Public Sub CreateSugarDataReader(mySelectQuery As String, _
sugarConnectionString As String)
  Dim sugarConnection As New SugarConnection(sugarConnectionString)
  Dim sugarCommand As New SugarCommand(mySelectQuery, sugarConnection)
  sugarCommand.Connection.Open()
  Dim sugarReader As SugarDataReader = sugarCommand.ExecuteReader(CommandBehavior.CloseConnection)
  While sugarReader.Read()
    Console.WriteLine(sugarReader.GetString(0))
  End While
  sugarReader.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