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. General Programming
  3. Visual Basic
  4. parent/child bindingsource save new fails

parent/child bindingsource save new fails

Scheduled Pinned Locked Moved Visual Basic
databasewpfwcfdesignhelp
3 Posts 2 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.
  • P Offline
    P Offline
    PrissySC
    wrote on last edited by
    #1

    Parent = context.table child = From t in parent where ... In properties, the datasource is set to parent as well. The bindingnavigators.bindingsource are set to child, all controls and datagrids are bound to the child bindingsoure. Add new will instaniate a new row. It displays in the datagrids; however, it will not save. The primary key field maintains 0. As soon as I sort or call a new query the row is gone. On reload the row is gone. Is there a problem with a child binding source? me.validate() me.parentsource.endedit() me.child.endedit() parent.resetcurrentitem() me.context.submitchanges() I have tried ending edit in reverse order and not reseting the current item (needed to update the changes, which works correctly for some strange crazy reason). The problem exists solely with saving a new row. Does it make a difference that there are two binding navigators? Due to space and design, I opted for 2, but I have tried the addnew on the second. Hmmm ... Ideas? :^)

    L 1 Reply Last reply
    0
    • P PrissySC

      Parent = context.table child = From t in parent where ... In properties, the datasource is set to parent as well. The bindingnavigators.bindingsource are set to child, all controls and datagrids are bound to the child bindingsoure. Add new will instaniate a new row. It displays in the datagrids; however, it will not save. The primary key field maintains 0. As soon as I sort or call a new query the row is gone. On reload the row is gone. Is there a problem with a child binding source? me.validate() me.parentsource.endedit() me.child.endedit() parent.resetcurrentitem() me.context.submitchanges() I have tried ending edit in reverse order and not reseting the current item (needed to update the changes, which works correctly for some strange crazy reason). The problem exists solely with saving a new row. Does it make a difference that there are two binding navigators? Due to space and design, I opted for 2, but I have tried the addnew on the second. Hmmm ... Ideas? :^)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      PrissySC wrote:

      I have tried ending edit in reverse order and not reseting the current item (needed to update the changes, which works correctly for some strange crazy reason). The problem exists solely with saving a new row.

      ..when there's no parent to link the children to. Save the parent first, without any children.

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

      P 1 Reply Last reply
      0
      • L Lost User

        PrissySC wrote:

        I have tried ending edit in reverse order and not reseting the current item (needed to update the changes, which works correctly for some strange crazy reason). The problem exists solely with saving a new row.

        ..when there's no parent to link the children to. Save the parent first, without any children.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] They hate us for our freedom![^]

        P Offline
        P Offline
        PrissySC
        wrote on last edited by
        #3

        After fighting with this and reading your comment ... I finally figured out the connection with the new to the relationship of the parent. It was not the actual save for the context that caused the problem, but rather how I was initiating the "new". parent.add(child.add) solved the problem. Now, when saving the changes to the context, no error and I get validation. Off to fight with excel export ... :~ Thanks for your comment!

        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