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

QuickBooksConnection Class
Represents an open connection to QuickBooks Online.
Syntax
Remarks

A QuickBooksConnection object represents a unique connection to QuickBooks Online. Use it in conjunction with QuickBooksCommand, QuickBooksDataReader, QuickBooksDataAdapter or other components for convenient interoperation with QuickBooks Online.

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

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

Note that QuickBooksConnection instance is not guaranteed to be thread safe. You should avoid using the same QuickBooksConnection 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 QuickBooksConnection can be used by many QuickBooksCommand 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 QuickBooksCommand and a QuickBooksConnection. The QuickBooksConnection 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 quickBooksConnectionString)
{
  // If the connection string is empty, use default.
  if(quickBooksConnectionString == "")
  {
    quickBooksConnectionString = 
        "Company Id=1440905870;Refresh Token=AB11590759756UCO8O6CpRQcAMP00sIANafgS8Y4RN10rpLJNM;Token Server=file://D:\\temp\\QuickBooksToken.txt";
  }
  QuickBooksConnection myConn = new QuickBooksConnection(quickBooksConnectionString);
  string myInsertQuery = "INSERT INTO Customer (DisplayName, Notes) VALUES ('John Smith', 'VIP Customer')";
  QuickBooksCommand quickBooksCommand = new QuickBooksCommand(myInsertQuery);
  quickBooksCommand.Connection = myConn;
  myConn.Open();
  try
  {
    quickBooksCommand.ExecuteNonQuery();
  }
  finally
  {
    myConn.Close();
  }
}
Public Sub InsertRow(quickBooksConnectionString As String)
  ' If the connection string is empty, use default.
  If quickBooksConnectionString = "" Then
    quickBooksConnectionString = _
        "Company Id=1440905870;Refresh Token=AB11590759756UCO8O6CpRQcAMP00sIANafgS8Y4RN10rpLJNM;Token Server=file://D:\\temp\\QuickBooksToken.txt"
  End If
  Dim myConn As New QuickBooksConnection(quickBooksConnectionString)
  Dim myInsertQuery As String = "INSERT INTO Customer (DisplayName, Notes) VALUES ('John Smith', 'VIP Customer')"
  Dim quickBooksCommand As New QuickBooksCommand(myInsertQuery)
  quickBooksCommand.Connection = myConn
  myConn.Open()
  Try
    quickBooksCommand.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.QuickBooks.QuickBooksConnection

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