QuickBooksCommandBuilder Class
Automatically generates single-table commands used to reconcile changes made to a
System.Data.DataSet with the QuickBooks Online.
The following example uses
QuickBooksCommand, along with
QuickBooksDataAdapter and
QuickBooksConnection, to select rows from QuickBooks Online. 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 QuickBooks Online table. The example then creates a
QuickBooksCommandBuilder.
|
|---|
public DataSet SelectQuickBooksSrvRows(DataSet myDataSet,string quickBooksConnection,string mySelectQuery,string myTableName)
{
QuickBooksConnection myConn = new QuickBooksConnection(quickBooksConnection);
QuickBooksDataAdapter myDataAdapter = new QuickBooksDataAdapter();
myDataAdapter.SelectCommand = new QuickBooksCommand(mySelectQuery, myConn);
QuickBooksCommandBuilder quickBooksCommandBuilder = new QuickBooksCommandBuilder(myDataAdapter);
myConn.Open();
DataSet myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet, "Departments");
//code to modify data in dataset here
//Without the QuickBooksCommandBuilder this line would fail
myDataAdapter.Update(myDataSet, "Departments");
myConn.Close();
return myDataSet;
} |
|
|---|
Public Function SelectQuickBooksSrvRows(myDataSet As DataSet, quickBooksConnection As String, mySelectQuery As String, myTableName As String) As DataSet
Dim myConn As New QuickBooksConnection(quickBooksConnection)
Dim myDataAdapter As New QuickBooksDataAdapter()
myDataAdapter.SelectCommand = New QuickBooksCommand(mySelectQuery, myConn)
Dim quickBooksCommandBuilder As QuickBooksCommandBuilder = New QuickBooksCommandBuilder(myDataAdapter)
myConn.Open()
Dim myDataSet As DataSet = New DataSet
myDataAdapter.Fill(myDataSet, "Departments")
' Code to modify data in DataSet here
' Without the QuickBooksCommandBuilder this line would fail.
myDataAdapter.Update(myDataSet, "Departments")
myConn.Close()
SelectQuickBooksSrvRows = myDataSet
End Function |