dotConnect for FreshBooks Documentation
Devart.Data.FreshBooks Namespace / FreshBooksCommand Class / ExecuteReader Method / ExecuteReader() Method
Example

On this page
    ExecuteReader() Method
    On this page
    Sends the CommandText to the Connection and builds a FreshBooksDataReader.
    Syntax
    'Declaration
     
    Public Overloads Shadows Function ExecuteReader() As FreshBooksDataReader
    public new FreshBooksDataReader ExecuteReader()

    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.
    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();
      try
      {
        while(freshBooksReader.Read())
        {
          Console.WriteLine(freshBooksReader.GetString(0));
        }
      }
      finally
      {
        freshBooksReader.Close();
        freshBooksConnection.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()
      Try
        While freshBooksReader.Read()
          Console.WriteLine(freshBooksReader.GetString(0))
        End While
      Finally
        freshBooksReader.Close()
        freshBooksConnection.Close()
      End Try
    End Sub
    See Also