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