ExactTargetConnection Class
Represents an open connection to ExactTarget.
The following example creates a
ExactTargetCommand and a
ExactTargetConnection. The
ExactTargetConnection 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 exactTargetConnectionString)
{
// If the connection string is empty, use default.
if(exactTargetConnectionString == "")
{
exactTargetConnectionString =
"user=MyCompanyAdmin;password=mypassword;url=https://webservice.s7.exacttarget.com/Service.asmx;";
}
ExactTargetConnection myConn = new ExactTargetConnection(exactTargetConnectionString);
string myInsertQuery = "INSERT INTO Email (Name, Subject) VALUES ('Sale', 'Big Sale!')";
ExactTargetCommand exactTargetCommand = new ExactTargetCommand(myInsertQuery);
exactTargetCommand.Connection = myConn;
myConn.Open();
try
{
exactTargetCommand.ExecuteNonQuery();
}
finally
{
myConn.Close();
}
}
Public Sub InsertRow(exactTargetConnectionString As String)
' If the connection string is empty, use default.
If exactTargetConnectionString = "" Then
exactTargetConnectionString = _
"user=MyCompanyAdmin;password=mypassword;url=https://webservice.s7.exacttarget.com/Service.asmx;"
End If
Dim myConn As New ExactTargetConnection(exactTargetConnectionString)
Dim myInsertQuery As String = "INSERT INTO Email (Name, Subject) VALUES ('Sale', 'Big Sale!')"
Dim exactTargetCommand As New ExactTargetCommand(myInsertQuery)
exactTargetCommand.Connection = myConn
myConn.Open()
Try
exactTargetCommand.ExecuteNonQuery()
Finally
myConn.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