MailChimpConnection Class
Represents an open connection to Mailchimp.
The following example creates a
MailChimpCommand and a
MailChimpConnection. The
MailChimpConnection is opened and set as the
Connection property. The example then calls
ExecuteNonQuery method, and closes the connection. To accomplish this, the
ExecuteNonQuery is passed a connection string and a query string that is SQL INSERT statement.
|
|---|
public void InsertRow(string mailchimpConnectionString)
{
// If the connection string is empty, use default.
if(mailchimpConnectionString == "")
{
mailchimpConnectionString =
"api key=8b10fe893c9732d12befe0b7d846ffcb-us10;";
}
MailChimpConnection myConn = new MailChimpConnection(mailchimpConnectionString);
string myInsertQuery = "INSERT INTO Folders(Name, Type) VALUES ('Sales', 'campaign')";
MailChimpCommand mailchimpCommand = new MailChimpCommand(myInsertQuery);
mailchimpCommand.Connection = myConn;
myConn.Open();
try
{
mailchimpCommand.ExecuteNonQuery();
}
finally
{
myConn.Close();
}
} |
|
|---|
Public Sub InsertRow(mailchimpConnectionString As String)
' If the connection string is empty, use default.
If mailchimpConnectionString = "" Then
mailchimpConnectionString = _
"api key=8b10fe893c9732d12befe0b7d846ffcb-us10;"
End If
Dim myConn As New MailChimpConnection(mailchimpConnectionString)
Dim myInsertQuery As String = "INSERT INTO Folders(Name, Type) VALUES ('Sales', 'campaign')"
Dim mailchimpCommand As New MailChimpCommand(myInsertQuery)
mailchimpCommand.Connection = myConn
myConn.Open()
Try
mailchimpCommand.ExecuteNonQuery()
Finally
myConn.Close()
End Try
End Sub |