BigcommerceConnection Class
Represents an open connection to BigCommerce.
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
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