dotConnect for Salesforce Marketing Cloud Documentation
Devart.Data.ExactTarget Namespace / ExactTargetCommandBuilder Class
Members Example

In This Topic
    ExactTargetCommandBuilder Class
    In This Topic
    Automatically generates single-table commands used to reconcile changes made to a System.Data.DataSet with the ExactTarget.
    Syntax
    'Declaration
     
    Public Class ExactTargetCommandBuilder 
       Inherits Devart.Data.SqlShimCommandBuilder
       Implements System.ComponentModel.IComponentSystem.IDisposable 
    Remarks

    The ExactTargetDataAdapter does not automatically generate the SQL statements required to reconcile changes made to a System.Data.DataSet associated with ExactTarget. However, you can create a ExactTargetCommandBuilder object that generates SQL statements for single-table updates. After assigning the ExactTargetDataAdapter to the ExactTargetCommandBuilder, it begins to generate any additional SQL statements that you do not set.

    The relationship between a ExactTargetDataAdapter and its corresponding ExactTargetCommandBuilder is always one-to-one. To create this correspondence, you set the DataAdapter property of the ExactTargetCommandBuilder object. This causes the ExactTargetCommandBuilder to register itself as a listener, which produces the output of ExactTargetDataAdapter.RowUpdating events that affect the System.Data.DataSet.

    To generate INSERT, UPDATE, or DELETE statements, the ExactTargetCommandBuilder uses the ExactTargetDataAdapter.SelectCommand property to retrieve a required set of metadata. If you change the value of ExactTargetDataAdapter.SelectCommand after the metadata has been retrieved (for example, after the first update), you then should call the Devart.Common.DbCommandBuilderBase.RefreshSchema method to update the metadata.

    The ExactTargetCommandBuilder also uses the Connection, CommandTimeout, and System.Data.Common.DbCommand.Transaction properties referenced by the ExactTargetDataAdapter.SelectCommand. The user should call Devart.Common.DbCommandBuilderBase.RefreshSchema if any of these properties are modified, or value of the ExactTargetDataAdapter.SelectCommand property itself is changed. Otherwise the ExactTargetDataAdapter.InsertCommand, ExactTargetDataAdapter.UpdateCommand, and ExactTargetDataAdapter.DeleteCommand properties retain their previous values.

    If you assign null to corresponding property of ExactTargetDataAdapter, the ExactTargetCommandBuilder will be disassociated from the ExactTargetDataAdapter, and the generated commands will no longer be used.

    Note: This class is not available in .NET Standard 1.3 compatible assembly. It is available only in the assembly for full .NET Framework and .NET Standard 2.0 compatible assembly.

    Example
    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
    Inheritance Hierarchy

    System.Object
       System.MarshalByRefObject
          System.ComponentModel.Component
             System.Data.Common.DbCommandBuilder
                Devart.Common.DbCommandBuilderBase
                   Devart.Common.DbCommandBuilder
                      Devart.Data.SqlShimCommandBuilder
                         Devart.Data.ExactTarget.ExactTargetCommandBuilder

    Requirements

    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

    See Also