Represents a SQL statement or stored procedure to execute against Mailchimp.
The following example uses the
ExecuteReader method of
MailChimpCommand, along with
MailChimpDataReader and
MailChimpConnection, to select rows from a table.
public void ReadMyData(string myConnString)
{
string mySelectQuery = "SELECT Id, Name FROM Folders";
MailChimpConnection mailchimpConnection = new MailChimpConnection(myConnString);
MailChimpCommand mailchimpCommand = new MailChimpCommand(mySelectQuery,mailchimpConnection);
mailchimpConnection.Open();
MailChimpDataReader mailchimpReader = mailchimpCommand.ExecuteReader();
try
{
while (mailchimpReader.Read())
{
Console.WriteLine(mailchimpReader.GetInt32(0).ToString() + ", " + mailchimpReader.GetString(1));
}
}
finally
{
// always call Close when done reading.
mailchimpReader.Close();
// always call Close when done reading.
mailchimpConnection.Close();
}
}
Public Sub ReadMyData(myConnString As String)
Dim mySelectQuery As String = "SELECT Id, Name FROM Folders"
Dim mailchimpConnection As New MailChimpConnection(myConnString)
Dim mailchimpCommand As New MailChimpCommand(mySelectQuery, mailchimpConnection)
mailchimpConnection.Open()
Dim mailchimpReader As MailChimpDataReader = mailchimpCommand.ExecuteReader()
Try
While mailchimpReader.Read()
Console.WriteLine(mailchimpReader.GetInt32(0).ToString() + ", " _
+ mailchimpReader.GetString(1))
End While
Finally
' always call Close when done reading.
mailchimpReader.Close()
' always call Close when done with connection.
mailchimpConnection.Close()
End Try
End Sub
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