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

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

    Parameters

    behavior
    One of the System.Data.CommandBehavior values.

    Return Value

    Example
    The following example creates a FreshBooksCommand, 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 CreateFreshBooksDataReader(string mySelectQuery,string freshBooksConnectionString)
    {
      FreshBooksConnection freshBooksConnection = new FreshBooksConnection(freshBooksConnectionString);
      FreshBooksCommand freshBooksCommand = new FreshBooksCommand(mySelectQuery, freshBooksConnection);
      freshBooksCommand.Connection.Open();
      FreshBooksDataReader freshBooksReader = freshBooksCommand.ExecuteReader(CommandBehavior.CloseConnection);
      while(freshBooksReader.Read())
      {
        Console.WriteLine(freshBooksReader.GetString(0));
      }
      freshBooksReader.Close();
    }
    Public Sub CreateFreshBooksDataReader(mySelectQuery As String, _
    freshBooksConnectionString As String)
      Dim freshBooksConnection As New FreshBooksConnection(freshBooksConnectionString)
      Dim freshBooksCommand As New FreshBooksCommand(mySelectQuery, freshBooksConnection)
      freshBooksCommand.Connection.Open()
      Dim freshBooksReader As FreshBooksDataReader = freshBooksCommand.ExecuteReader(CommandBehavior.CloseConnection)
      While freshBooksReader.Read()
        Console.WriteLine(freshBooksReader.GetString(0))
      End While
      freshBooksReader.Close()
    End Sub
    See Also