dotConnect for BigCommerce Documentation
Devart.Data.Bigcommerce Namespace / BigcommerceCommandBuilder Class
Members Example

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

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

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

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

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

    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