|
-
Feb 17th, 2011, 01:49 AM
#1
Thread Starter
Addicted Member
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
-
Feb 17th, 2011, 06:22 PM
#2
Re: how to insert data from checkedlistbox into database?
 Originally Posted by nebrom
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|