BigcommerceCommandBuilder Class
Automatically generates single-table commands used to reconcile changes made to a
System.Data.DataSet with the BigCommerce.
The following example uses
BigcommerceCommand, along with
BigcommerceDataAdapter and
BigcommerceConnection, to select rows from BigCommerce. The example is passed an initialized
System.Data.DataSet, a connection string, a query string that is SQL SELECT statement, and a string that is the name of the BigCommerce table. The example then creates a
BigcommerceCommandBuilder.
public DataSet SelectBigcommerceSrvRows(DataSet myDataSet,string bigcommerceConnection,string mySelectQuery,string myTableName)
{
BigcommerceConnection myConn = new BigcommerceConnection(bigcommerceConnection);
BigcommerceDataAdapter myDataAdapter = new BigcommerceDataAdapter();
myDataAdapter.SelectCommand = new BigcommerceCommand(mySelectQuery, myConn);
BigcommerceCommandBuilder bigcommerceCommandBuilder = new BigcommerceCommandBuilder(myDataAdapter);
myConn.Open();
DataSet myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet, "Departments");
//code to modify data in dataset here
//Without the BigcommerceCommandBuilder this line would fail
myDataAdapter.Update(myDataSet, "Departments");
myConn.Close();
return myDataSet;
}
Public Function SelectBigcommerceSrvRows(myDataSet As DataSet, bigcommerceConnection As String, mySelectQuery As String, myTableName As String) As DataSet
Dim myConn As New BigcommerceConnection(bigcommerceConnection)
Dim myDataAdapter As New BigcommerceDataAdapter()
myDataAdapter.SelectCommand = New BigcommerceCommand(mySelectQuery, myConn)
Dim bigcommerceCommandBuilder As BigcommerceCommandBuilder = New BigcommerceCommandBuilder(myDataAdapter)
myConn.Open()
Dim myDataSet As DataSet = New DataSet
myDataAdapter.Fill(myDataSet, "Departments")
' Code to modify data in DataSet here
' Without the BigcommerceCommandBuilder this line would fail.
myDataAdapter.Update(myDataSet, "Departments")
myConn.Close()
SelectBigcommerceSrvRows = myDataSet
End Function