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. Database & SysAdmin
  3. Database
  4. ADO.NET - BindingContext and Disappearing Rows

ADO.NET - BindingContext and Disappearing Rows

Scheduled Pinned Locked Moved Database
csharpdatabasedebuggingquestion
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.
  • M Offline
    M Offline
    mikasa
    wrote on last edited by
    #1

    I am using a DataSet which contains two DataTables. The 2 Tables are related using a DataRelation and it's a One-to-One Relationship. On a Form, I create a DataView for the Top-Level Parent Table and access the Child table through the DataMember when using the BindingContext. One my Form, I am using Me.BindingContext(dvData).AddNew() for the Parent Table. I then use Me.BindingContext(dvData, "ChildRelationship").AddNew() to Add a new Record at the Child Level. I do this because the Form edits data in both Tables at the same time so that to the User, they will not have to make 2 edits just to get data in both tables. When I debug after doing this, everything is great! I can see both new Rows added to the DataView and the Form works as expected since it is data bound. However, in my Save Routine, I modify a few Columns if the Data wasn't supplied, and lastly call the Me.BindingContext(dvData).EndCurrentEdit() and Me.BindingContext(dvData, "ChildRelationship").EndCurrentEdit(). When I do this, and attempt to save the Data back to the Database, it has the Parent Row, but the Child Table's Row (that was previously there) is no longer there! Filtering the DataTable on only Modified / New Rows results in no data, and also the Row Count is the same as before any Rows were added. It's as if the New Row on the Child Table just disappeared!!! :wtf: Does anyone have any insight?? :confused:

    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