Overview

DataAdapter

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/3cc36160-7aa2-4e88-8e11-f2cad9ef8ee8/Untitled.png

using (var connection = new SqlConnection("..."))
{
    var dataAdpater = new SqlDataAdapter("SELECT CategoryID, CategoryName FROM Categories", connection.ConnectionString)
    {
        UpdateCommand = new SqlCommand(
            "UPDATE Categories SET CategoryName = @CategoryName WHERE CategoryID = @CategoryID", connection)
    };
    var parameter = dataAdpater.UpdateCommand.Parameters.Add("@CategoryID", SqlDbType.Int);
    parameter.SourceColumn = "CategoryID";
    parameter.SourceVersion = DataRowVersion.Original;

    dataAdpater.UpdateCommand.Parameters.Add("@CategoryName", SqlDbType.NVarChar, 15, "CategoryName");

    var categoryTable = new DataTable();
    dataAdpater.Fill(categoryTable);

    var categoryRow = categoryTable.Rows[0];
    categoryRow["CategoryName"] = "New Beverages";

    dataAdpater.Update(categoryTable);

    foreach (DataRow row in categoryTable.Rows)
        Console.WriteLine("{0}: {1}", row[0], row[1]);
}

Ordering of Inserts, Updates, and Deletes

DataTable table = dataSet.Tables["Customers"];  

// First process deletes.  
adapter.Update(table.Select(null, null, DataViewRowState.Deleted));  

// Next process updates.
adapter.Update(table.Select(null, null, DataViewRowState.ModifiedCurrent));  

// Finally, process inserts.
adapter.Update(table.Select(null, null, DataViewRowState.Added));

DataView

DataView custDV1 = new DataView(custDS.Tables["Customers"],   
    "Country = 'USA'",
    "ContactName",
    DataViewRowState.CurrentRows);

DataView custDV2 = custDS.Tables["Customers"].DefaultView;

LINQ to DataSet