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','smithj@test1.com')";
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','smithj@test1.com')"
Dim bigcommerceCommand As New BigcommerceCommand(myInsertQuery)
bigcommerceCommand.Connection = myConn
myConn.Open()
Try
bigcommerceCommand.ExecuteNonQuery()
Finally
myConn.Close()
End Try
End Sub