Integration Your Way - (800) 235-7250
RSSBus ADO.NET Provider for SalesForce V2
Questions / Feedback? Updating the Data

Updating the Data

Use the adapter's Update method to update the data. This overloaded method can take a DataTable as a parameter and will commit all the changes made to the data source. The name of the data table can be passed as an argument as well to update the entire dataset in a more traditional manner. When using a data table as an argument to the Update method, the adapter evaluates the changes that have been made to the data table and executes the appropriate command for each row (INSERT, UPDATE, or DELETE).

The example below updates the Name of one of the Account entries.

  using (SalesForceConnection connection = new SalesForceConnection(connectionString)) {
    SalesForceDataAdapter dataAdapter = new SalesForceDataAdapter(
      "SELECT Id, Name FROM Account", connection);

    dataAdapter.UpdateCommand = new SalesForceCommand(
      "UPDATE Account SET Name = @Name " +
      "WHERE Id = @ID", connection);

    dataAdapter.UpdateCommand.Parameters.AddWithValue("@Name", "Name");
    dataAdapter.UpdateCommand.Parameters.AddWithValue("@Id", "Id");

    DataTable table = new DataTable();
    dataAdapter.Fill(table);

    DataRow firstrow = table.Rows[0];
    firstrow["Name"] = "Floppy Disks";

    dataAdapter.Update(table);

    Console.WriteLine("Rows after update.");
    
    foreach (DataRow row in table.Rows) {
      Console.WriteLine("{0}: {1}", row["Id"], row["Name"]);
    }
  }


 
Copyright © 2013 RSSBus Inc.
[x] close

Questions / Feedback?


Name:
Email:
Feedback:
Send Feedback