|
-
Feb 11th, 2011, 02:01 AM
#1
Thread Starter
Addicted Member
how to insert data from checkedlistbox into my sql database?
i am developing windows form application and my database is Sql server 2005.
i know how to insert from textbox into my table, but i got hard how to insert from checkedlistbox into my table.
my table(customerTable) has two columns, customerName, and room.
in my checkedlist box i have 1,2,,3,4,5........30,31,32 rooms list.
i can select one or more rooms at the same time, for example, in the textbox of customerName i insert: Girmay Mekelle
and the checkedlistBox lists: i can choose(tick) rooms: 10,13,18
then click add button,
then i expected the rooms in my table will be 10,13,18 and customerName:Girmay Mekelle.
so how do i insert from checkedlistbox into my table?
my second question is:
if you can solve the above problem then , how do i select rooms from my table so that i can list them in checkedlistBox?
i am a begginer and i tried to google it but i could not get the solution.
so please forward ur help towards me. thanks
-
Feb 11th, 2011, 06:20 AM
#2
Re: how to insert data from checkedlistbox into my sql database?
However you insert data from a TextBox is exactly how you insert data from a CheckedListBox. Data is data. It's how you get that data in the first place that differs depending on the source. The Text property of a TextBox is a String. To get Strings for checked items in a CheckedListBox, do something like this:
csharp Code:
foreach (var checkedItem in this.checkedListBox1.CheckedItems) { MessageBox.Show(this.checkedListBox1.GetItemText(checkedItem)); }
Last edited by jmcilhinney; Feb 11th, 2011 at 06:23 AM.
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
|