Results 1 to 2 of 2

Thread: how to insert data from checkedlistbox into database?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    208

    Question how to insert data from checkedlistbox into database?

    I am developing windows form application usind Sql server 2005 database and VS 2008.

    my table has two columns: name and room

    name is textbox while rooms are listed in checkedlistBox

    now i want to insert these values into my customerTbl:

    if i select more than one room, the room in my table will be separted by coma,

    if i select more than one rooms.

    then in my table it will be likes:

    name rooms

    Girmay 101,102,103

    Mike 103,104,110

    Lemlem 101,102



    so how would i insert data from checkedListBox into my table?
    help me please

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: how to insert data from checkedlistbox into database?

    Quote Originally Posted by nebrom View Post
    if i select more than one room, the room in my table will be separted by coma
    I would recommend against that. It's a much better idea to add an extra table to represent the relationship. You'd have one table with the person ID and Name, another with the room ID and Name or Number or whatever, then a third table that would contain the person ID and the room ID. If a person is related to three rooms then you add three records to the third table, each with the same person ID and a different room ID. It's for stuff like this that relational databases exist.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width