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

In This Topic
    BigcommerceConnection Class
    In This Topic
    Represents an open connection to BigCommerce.
    Syntax
    Remarks

    A BigcommerceConnection object represents a unique connection to BigCommerce. Use it in conjunction with BigcommerceCommand, BigcommerceDataReader, BigcommerceDataAdapter or other components for convenient interoperation with BigCommerce.

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

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

    Note that BigcommerceConnection instance is not guaranteed to be thread safe. You should avoid using the same BigcommerceConnection 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 BigcommerceConnection can be used by many BigcommerceCommand 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 BigcommerceCommand and a BigcommerceConnection. The BigcommerceConnection 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 bigcommerceConnectionString)
    {
      // If the connection string is empty, use default.
      if(bigcommerceConnectionString == "")
      {
        bigcommerceConnectionString = 
            "Server=https://bigcommerce-store.mybigcommerce.com/api/v2/;User Id=User;Authentication Token=qweASDzcx1234567890rtyuiqweASDzcx1234567;";
      }
      BigcommerceConnection myConn = new BigcommerceConnection(bigcommerceConnectionString);
      string myInsertQuery = "INSERT INTO customers (firstname, lastname, email) VALUES ('John','Smith','[email protected]')";
      BigcommerceCommand bigcommerceCommand = new BigcommerceCommand(myInsertQuery);
      bigcommerceCommand.Connection = myConn;
      myConn.Open();
      try
      {
        bigcommerceCommand.ExecuteNonQuery();
      }
      finally
      {
        myConn.Close();
      }
    }
    Public Sub InsertRow(bigcommerceConnectionString As String)
      ' If the connection string is empty, use default.
      If bigcommerceConnectionString = "" Then
        bigcommerceConnectionString = _
            "Server=https://bigcommerce-store.mybigcommerce.com/api/v2/;User Id=User;Authentication Token=qweASDzcx1234567890rtyuiqweASDzcx1234567;"
      End If
      Dim myConn As New BigcommerceConnection(bigcommerceConnectionString)
      Dim myInsertQuery As String = "INSERT INTO customers (firstname, lastname, email) VALUES ('John','Smith','[email protected]')"
      Dim bigcommerceCommand As New BigcommerceCommand(myInsertQuery)
      bigcommerceCommand.Connection = myConn
      myConn.Open()
      Try
        bigcommerceCommand.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.Bigcommerce.BigcommerceConnection

    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