dotConnect for Zoho Desk Documentation
Devart.Data.ZohoDesk Namespace / ZohoDeskConnection Class
Members Example

ZohoDeskConnection Class
Represents an open connection to Zoho Desk.
Syntax
Remarks

A ZohoDeskConnection object represents a unique connection to Zoho Desk. Use it in conjunction with ZohoDeskCommand, ZohoDeskDataReader, ZohoDeskDataAdapter or other components for convenient interoperation with Zoho Desk.

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

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

Note that ZohoDeskConnection instance is not guaranteed to be thread safe. You should avoid using the same ZohoDeskConnection 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 ZohoDeskConnection can be used by many ZohoDeskCommand 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.

Example
The following example creates a ZohoDeskCommand and a ZohoDeskConnection. The ZohoDeskConnection 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 ZohoDeskConnectionString)
{
  // If the connection string is empty, use default.
  if(ZohoDeskConnectionString == "")
  {
    ZohoDeskConnectionString = 
        Refresh Token=1000.a6fde76542bfbb5244a7e539d4390e72.87e34ea57023c2d0e7dcb9ce55e3e7f;
  }
  ZohoDeskConnection myConn = new ZohoDeskConnection(ZohoDeskConnectionString);
  string myInsertQuery = "INSERT INTO Accounts (\"Account Name\", Phone) VALUES ('Test','555-555-555')";
  ZohoDeskCommand ZohoDeskCommand = new ZohoDeskCommand(myInsertQuery);
  ZohoDeskCommand.Connection = myConn;
  myConn.Open();
  try
  {
    ZohoDeskCommand.ExecuteNonQuery();
  }
  finally
  {
    myConn.Close();
  }
}
Public Sub InsertRow(ZohoDeskConnectionString As String)
  ' If the connection string is empty, use default.
  If ZohoDeskConnectionString = "" Then
    ZohoDeskConnectionString = _
        Refresh Token=1000.a6fde76542bfbb5244a7e539d4390e72.87e34ea57023c2d0e7dcb9ce55e3e7f
  End If
  Dim myConn As New ZohoDeskConnection(ZohoDeskConnectionString)
  Dim myInsertQuery As String = "INSERT INTO Accounts (\"Account Name\", Phone) VALUES ('Test','555-555-555')"
  Dim ZohoDeskCommand As New ZohoDeskCommand(myInsertQuery)
  ZohoDeskCommand.Connection = myConn
  myConn.Open()
  Try
    ZohoDeskCommand.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.ZohoDesk.ZohoDeskConnection

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