dotConnect for Zoho CRM Documentation
Devart.Data.Zoho Namespace / ZohoCommandBuilder Class
Members Example

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

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

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

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

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

    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