MailChimpDataReader Class
Reads a forward-only stream of rows from Mailchimp.
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 |