Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. LoadOption.OverwriteChanges - Functionlaity [modified]

LoadOption.OverwriteChanges - Functionlaity [modified]

Scheduled Pinned Locked Moved ASP.NET
databaseworkspace
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Satish32
    wrote on last edited by
    #1

    <I have written code to test the SqlDataAdaptor's LoadOpton functionality for LoadOption.OverwriteChanges. But the code that i written is not working.. Values are not getting overwritten Here are the values which i am getting when i run the code ***Default*** Original Value: Chai, Current Value: Chai ***Values Before Reload*** Original Value: Chai, Current Value: Coffee ***LoadOption.OverwriteChanges;*** Original Value: Chai, Current Value: Coffee Expected results are ***Default*** Original Value: Chai, Current Value: Chai ***Values Before Reload*** Original Value: Chai, Current Value: Coffee ***LoadOption.OverwriteChanges;*** Original Value: Chai, Current Value: Chai Here is the code which i have written. i scratched my head almost 2hrs couln't get any answer. Please let me know where i have done wrong.. protected void Page_Load(object sender, EventArgs e) { DataSet poductsDS = new DataSet(); string query = "Select ProductName, UnitPrice from Products"; string _conStr = System.Configuration.ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString; SqlDataAdapter da = new SqlDataAdapter(query,_conStr); da.Fill(productsDS); Display(productsDS, "Default"); //updating table filed values DataRow row = productsDS.Tables[0].Rows[0]; row["ProductName"] = "Coffee"; Display(productsDS, "Values Before Reload"); //Reloading SqlDataAdapter da2 = new SqlDataAdapter(query,_conStr); da2.FillLoadOption = LoadOption.OverwriteChanges; da2.Fill(productsDS); Display(productsDS, "LoadOption.OverwriteChanges;"); } private void Display(DataSet ds, string Heading) { Response.Write("***" + Heading + "***"); Response.Write("<br/>"); DataTable table = ds.Tables[0]; DataRow row = table.Rows[0]; Response.Write(string.Format("Original Value: {0}, Current Value: {1}", row[0, DataRowVersion.Original].ToString(), row[0, DataRowVersion.Current].ToString())); Response.Write("<br/>"); Response.Write("<br/>"); }

    Satish

    modified on Sunday, October 4, 2009 5:09 AM

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups