dotConnect for QuickBooks Online Documentation
Devart.Data.QuickBooks Namespace / QuickBooksCommandBuilder Class
Members Example

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

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

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

    To generate INSERT, UPDATE, or DELETE statements, the QuickBooksCommandBuilder uses the QuickBooksDataAdapter.SelectCommand property to retrieve a required set of metadata. If you change the value of QuickBooksDataAdapter.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 QuickBooksCommandBuilder also uses the Connection, CommandTimeout, and System.Data.Common.DbCommand.Transaction properties referenced by the QuickBooksDataAdapter.SelectCommand. The user should call Devart.Common.DbCommandBuilderBase.RefreshSchema if any of these properties are modified, or value of the QuickBooksDataAdapter.SelectCommand property itself is changed. Otherwise the QuickBooksDataAdapter.InsertCommand, QuickBooksDataAdapter.UpdateCommand, and QuickBooksDataAdapter.DeleteCommand properties retain their previous values.

    If you assign null to corresponding property of QuickBooksDataAdapter, the QuickBooksCommandBuilder will be disassociated from the QuickBooksDataAdapter, 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 QuickBooksCommand, along with QuickBooksDataAdapter and QuickBooksConnection, to select rows from QuickBooks Online. 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 QuickBooks Online table. The example then creates a QuickBooksCommandBuilder.
    public DataSet SelectQuickBooksSrvRows(DataSet myDataSet,string quickBooksConnection,string mySelectQuery,string myTableName)
    {
      QuickBooksConnection myConn = new QuickBooksConnection(quickBooksConnection);
      QuickBooksDataAdapter myDataAdapter = new QuickBooksDataAdapter();
      myDataAdapter.SelectCommand = new QuickBooksCommand(mySelectQuery, myConn);
      QuickBooksCommandBuilder quickBooksCommandBuilder = new QuickBooksCommandBuilder(myDataAdapter);
    
      myConn.Open();
    
      DataSet myDataSet = new DataSet();
      myDataAdapter.Fill(myDataSet, "Departments");
    
      //code to modify data in dataset here
    
      //Without the QuickBooksCommandBuilder this line would fail
      myDataAdapter.Update(myDataSet, "Departments");
    
      myConn.Close();
    
      return myDataSet;
    }
    Public Function SelectQuickBooksSrvRows(myDataSet As DataSet, quickBooksConnection As String, mySelectQuery As String, myTableName As String) As DataSet
      Dim myConn As New QuickBooksConnection(quickBooksConnection)
      Dim myDataAdapter As New QuickBooksDataAdapter()
      myDataAdapter.SelectCommand = New QuickBooksCommand(mySelectQuery, myConn)
      Dim quickBooksCommandBuilder As QuickBooksCommandBuilder = New QuickBooksCommandBuilder(myDataAdapter)
    
      myConn.Open()
    
      Dim myDataSet As DataSet = New DataSet
      myDataAdapter.Fill(myDataSet, "Departments")
    
      ' Code to modify data in DataSet here
    
      ' Without the QuickBooksCommandBuilder this line would fail.
      myDataAdapter.Update(myDataSet, "Departments")
    
      myConn.Close()
    
      SelectQuickBooksSrvRows = 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.QuickBooks.QuickBooksCommandBuilder

    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