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

In This Topic
    ZohoConnection Class
    In This Topic
    Represents an open connection to Zoho CRM.
    Syntax
    Remarks

    A ZohoConnection object represents a unique connection to Zoho CRM. Use it in conjunction with ZohoCommand, ZohoDataReader, ZohoDataAdapter or other components for convenient interoperation with Zoho CRM.

    When you create an instance of ZohoConnection, all properties are set to their initial values. For a list of these values, see ConnectionString.

    If the ZohoConnection goes out of scope, it is not closed. Therefore, you must explicitly close the connection by calling Close.

    Note that ZohoConnection instance is not guaranteed to be thread safe. You should avoid using the same ZohoConnection in several threads at the same time. It is recommended to open a new connection per thread and to close it when the work is done. Actually, connections will not be created/disposed every time with the Pooling=true; connection string option - connections will be stored at connection pool. This boosts performance greatly.

    A single ZohoConnection can be used by many ZohoCommand objects on the assumption that all operations will be done consecutively. In other words, you can not execute a SQL statement while an asynchronous operation is in progress.

    This class supports cross-form data binding with the InterForm Technology.

    Example
    The following example creates a ZohoCommand and a ZohoConnection. The ZohoConnection is opened and set as the Connection property. The example then calls ExecuteNonQuery method, and closes the connection. To accomplish this, the ExecuteNonQuery is passed a connection string and a query string that is SQL INSERT statement.
    public void InsertRow(string zohoConnectionString)
    {
      // If the connection string is empty, use default.
      if(zohoConnectionString == "")
      {
        zohoConnectionString = 
            "API Version=V2;Refresh Token=1000.a6fde76542bfbb5244a7e539d4390e72.87e34ea57023c2d0e7dcb9ce55e3e7f3;ClientId=1000.M4FJLKYTSED90LJHUTVMKKAA432RUK;ClientSecret=89a0ed79957808814cdb20b9765423efffa767d1d0";
      }
      ZohoConnection myConn = new ZohoConnection(zohoConnectionString);
      string myInsertQuery = "INSERT INTO Accounts (\"Account Name\", Phone) VALUES ('Test','555-555-555')";
      ZohoCommand zohoCommand = new ZohoCommand(myInsertQuery);
      zohoCommand.Connection = myConn;
      myConn.Open();
      try
      {
        zohoCommand.ExecuteNonQuery();
      }
      finally
      {
        myConn.Close();
      }
    }
    Public Sub InsertRow(zohoConnectionString As String)
      ' If the connection string is empty, use default.
      If zohoConnectionString = "" Then
        zohoConnectionString = _
            "API Version=V2;Refresh Token=1000.a6fde76542bfbb5244a7e539d4390e72.87e34ea57023c2d0e7dcb9ce55e3e7f3;ClientId=1000.M4FJLKYTSED90LJHUTVMKKAA432RUK;ClientSecret=89a0ed79957808814cdb20b9765423efffa767d1d0"
      End If
      Dim myConn As New ZohoConnection(zohoConnectionString)
      Dim myInsertQuery As String = "INSERT INTO Accounts (\"Account Name\", Phone) VALUES ('Test','555-555-555')"
      Dim zohoCommand As New ZohoCommand(myInsertQuery)
      zohoCommand.Connection = myConn
      myConn.Open()
      Try
        zohoCommand.ExecuteNonQuery()
      Finally
        myConn.Close()
      End Try
    End Sub
    Inheritance Hierarchy

    System.Object
       System.MarshalByRefObject
          System.ComponentModel.Component
             System.Data.Common.DbConnection
                Devart.Common.DbConnectionBase
                   Devart.Data.SqlShimConnection
                      Devart.Data.Zoho.ZohoConnection

    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