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. C#
  4. DataRows with no primary key, and listbox items

DataRows with no primary key, and listbox items

Scheduled Pinned Locked Moved C#
helptutorial
2 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.
  • L Offline
    L Offline
    Lodeclaw
    wrote on last edited by
    #1

    Hello all. I'm working on a portion of a program I'm writing that involves creating new rows in a table that has no primary key and two foreign keys. The rows in the datatable are invoice details for rented items. I want to be able to get this new row and place it's contents in a listbox, followed up by a number of similar new rows in the same listbox. I'm not sure how (if it's possible,) to retrieve the new row since it has no primary key. I'm also not sure then how to associate the datarow with it's respective item in the listbox. My hope is to be able to, when necessary, select the item in the listbox and use it to delete the row it's associated with from the datatable. I'm going out on a limb here hoping someone might have some advice or can point me in the right direction. Any help would be hugely appreciated. Thanks in advance!

    W 1 Reply Last reply
    0
    • L Lodeclaw

      Hello all. I'm working on a portion of a program I'm writing that involves creating new rows in a table that has no primary key and two foreign keys. The rows in the datatable are invoice details for rented items. I want to be able to get this new row and place it's contents in a listbox, followed up by a number of similar new rows in the same listbox. I'm not sure how (if it's possible,) to retrieve the new row since it has no primary key. I'm also not sure then how to associate the datarow with it's respective item in the listbox. My hope is to be able to, when necessary, select the item in the listbox and use it to delete the row it's associated with from the datatable. I'm going out on a limb here hoping someone might have some advice or can point me in the right direction. Any help would be hugely appreciated. Thanks in advance!

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      Lodeclaw wrote:

      I'm writing that involves creating new rows in a table that has no primary key and two foreign keys

      Isn't there any natural key present? Also could you create a key column in your datatable and let the datatable to generate a unique value to it?

      Lodeclaw wrote:

      followed up by a number of similar new rows in the same listbox

      How do you recognize similarity?

      Lodeclaw wrote:

      I'm also not sure then how to associate the datarow with it's respective item in the listbox

      If I understood correctly your problem in this, you would use ValueMember[^] definition in your binding.

      Lodeclaw wrote:

      use it to delete the row it's associated with from the datatable

      When the listbox is binded to the datatable, you would actually delete the row from the datatable. The listbox reflects the changes in your datatable.

      The need to optimize rises from a bad design.My articles[^]

      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