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 |