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. ListBox linked to Database

ListBox linked to Database

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

    I have a database that contains 2 tables. The first called Users contains username and password the second called PhoneNumbers contains a primary key called PhoneNumberID, a User column and a column with the telephone numbers of the users, that can be 0, 1 or more. There is a relationship one-two-many between the username in the Users table and the username in the PhoneNumbers table. Now I want to make an application that displays the phone numbers of a given user and allows to add or delete new numbers. I thought that the best method is to use a listBox, a texBox and two buttons, add and remove. The user loads the data from the database, populate the listBox, selectt a number and clicks delete, and the number is deleted. Write a number in the textBox and clicks add and the number is added. I make this through an XML Web Service. I have a method that takes username and password, and returns a DataSet to the clien. Than i use foreach to add all the returned phone numbers to the listbox. Now THE QUESTION: How I manage the update? If a user added a phone number, the update should add a row to the database, if delete delete the corresponding row. When the user clicks the update button, the code should, check all the items actually in the listbox, determine if it was added, or know if some of the previously held was deleted. HOW I ACCOMPLISH THIS? And after this, how I create a link with the rows in the database, since the listbox, contains only the phone number value, but no primary key of the PhoneNumbers table? An help is greatly apreciated. "Nelle cose del mondo non e' il sapere ma il volere che puo'."

    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