dotConnect for Mailchimp Documentation
Devart.Data.MailChimp Namespace / MailChimpDataReader Class
Members Example

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

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

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

    System.Object
       System.MarshalByRefObject
          System.Data.Common.DbDataReader
             Devart.Common.DbDataReaderBase
                Devart.Data.SqlShimDataReader
                   Devart.Data.MailChimp.MailChimpDataReader

    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