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