ExactTargetCommandBuilder Class
Automatically generates single-table commands used to reconcile changes made to a
System.Data.DataSet with the ExactTarget.
The following example uses
ExactTargetCommand, along with
ExactTargetDataAdapter and
ExactTargetConnection, to select rows from ExactTarget. The example is passed an initialized
System.Data.DataSet, a connection string, a query string that is SQL SELECT statement, and a string that is the name of the ExactTarget table. The example then creates a
ExactTargetCommandBuilder.
public DataSet SelectExactTargetSrvRows(DataSet myDataSet,string exactTargetConnection,string mySelectQuery,string myTableName)
{
ExactTargetConnection myConn = new ExactTargetConnection(exactTargetConnection);
ExactTargetDataAdapter myDataAdapter = new ExactTargetDataAdapter();
myDataAdapter.SelectCommand = new ExactTargetCommand(mySelectQuery, myConn);
ExactTargetCommandBuilder exactTargetCommandBuilder = new ExactTargetCommandBuilder(myDataAdapter);
myConn.Open();
DataSet myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet, "Departments");
//code to modify data in dataset here
//Without the ExactTargetCommandBuilder this line would fail
myDataAdapter.Update(myDataSet, "Departments");
myConn.Close();
return myDataSet;
}
Public Function SelectExactTargetSrvRows(myDataSet As DataSet, exactTargetConnection As String, mySelectQuery As String, myTableName As String) As DataSet
Dim myConn As New ExactTargetConnection(exactTargetConnection)
Dim myDataAdapter As New ExactTargetDataAdapter()
myDataAdapter.SelectCommand = New ExactTargetCommand(mySelectQuery, myConn)
Dim exactTargetCommandBuilder As ExactTargetCommandBuilder = New ExactTargetCommandBuilder(myDataAdapter)
myConn.Open()
Dim myDataSet As DataSet = New DataSet
myDataAdapter.Fill(myDataSet, "Departments")
' Code to modify data in DataSet here
' Without the ExactTargetCommandBuilder this line would fail.
myDataAdapter.Update(myDataSet, "Departments")
myConn.Close()
SelectExactTargetSrvRows = myDataSet
End Function
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