dotConnect for Salesforce Marketing Cloud Documentation
Devart.Data.ExactTarget Namespace / ExactTargetDataReader Class
Members Example

In This Topic
    ExactTargetDataReader Class
    In This Topic
    Reads a forward-only stream of rows from ExactTarget.
    Syntax
    Remarks
    To create a ExactTargetDataReader, you must call the ExecuteReader method of the ExactTargetCommand object, rather than directly using a constructor.

    System.Data.Common.DbDataReader.IsClosed and RecordsAffected are the only properties that you can call after the ExactTargetDataReader is closed. In some cases, you must call Close before you can call RecordsAffected.

    Example
    The following example creates a ExactTargetConnection, a ExactTargetCommand, and a ExactTargetDataReader. The example reads through the data, writing it out to the console. Finally, the example closes the ExactTargetDataReader, then the ExactTargetConnection.
    public void ReadMyData(string myConnString)  {
            ExactTargetConnection exactTargetConnection = new ExactTargetConnection(myConnString);
            ExactTargetCommand exactTargetCommand = (ExactTargetCommand)exactTargetConnection.CreateCommand();
            exactTargetCommand.CommandText = "SELECT ID, Name, Subject FROM Email";
            exactTargetConnection.Open();
            ExactTargetDataReader exactTargetReader = exactTargetCommand.ExecuteReader();
            try {
                    // Always call Read before accessing data.
                    while (exactTargetReader.Read()) {
                    Console.WriteLine(exactTargetReader.GetInt32(0).ToString() + " " + 
                    exactTargetReader.GetString(1) + " " + exactTargetReader.GetString(2));
            }
            }
            finally {
                    // always call Close when done reading.
                    exactTargetReader.Close();
    
                    // Close the connection when done with it.
                    exactTargetConnection.Close();
            }
    }
    Public Sub ReadMyData(ByVal myConnString As String)
            Dim exactTargetConnection As New ExactTargetConnection(myConnString)
            Dim exactTargetCommand As ExactTargetCommand = exactTargetConnection.CreateCommand()
                    exactTargetCommand.CommandText = "SELECT ID, Name, Subject FROM Email"
            exactTargetConnection.Open()
            Dim exactTargetReader As ExactTargetDataReader = exactTargetCommand.ExecuteReader()
            Try
                    ' Always call Read before accessing data.
                    While exactTargetReader.Read()
                            Console.WriteLine(String.Concat(exactTargetReader.GetInt32(0).ToString(), " ", _
                            exactTargetReader.GetString(1), " ", exactTargetReader.GetString(2)))
                    End While
            Finally
                    ' always call Close when done reading.
                    exactTargetReader.Close()
    
                            ' Close the connection when done with it.
                            exactTargetConnection.Close()
            End Try
    End Sub
    Inheritance Hierarchy

    System.Object
       System.MarshalByRefObject
          System.Data.Common.DbDataReader
             Devart.Common.DbDataReaderBase
                Devart.Data.SqlShimDataReader
                   Devart.Data.ExactTarget.ExactTargetDataReader

    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