|
-
May 11th, 2007, 05:15 AM
#1
Thread Starter
Junior Member
Getting Multiple values from listbox to data base
Hi, how can i get multiple values in th listbox into my database???
-
May 14th, 2007, 03:22 PM
#2
Frenzied Member
Re: Getting Multiple values from listbox to data base
 Originally Posted by arunhere
Hi, how can i get multiple values in th listbox into my database??? 
Press the big red button at the center of your screen.
You need to be more specific.
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
May 20th, 2007, 11:56 PM
#3
Thread Starter
Junior Member
Re: Getting Multiple values from listbox to data base
In my interface i have used a listbox. I want to know how can i link it to the database and save only the selected values in the listbox.
-
May 21st, 2007, 01:26 AM
#4
Re: Getting Multiple values from listbox to data base
You're asking two completely separate questions. Getting data from a ListBox is one thing. Saving data to a database is something else. If you think of them as black boxes then the first one has a pipe for its output and the second has a pipe for its input. You just have to connect the two pipes together and the output from one operation becomes the input for the other, but you should design the boxes independently.
So, the SelectedItems property of a ListBox is a collection of the items that are selected. You can get them all by looping through the items with a For or For Each loop, e.g.
vb Code:
For Each item As String In myListBox.SelectedItems
MessageBox.Show(item)
Next item
Check out this page for information on ADO.NET.
-
May 21st, 2007, 05:30 AM
#5
Thread Starter
Junior Member
Re: Getting Multiple values from listbox to data base
But th code am looking for is in c#..........u have send me a vb code....
-
May 21st, 2007, 05:47 AM
#6
Re: Getting Multiple values from listbox to data base
Woops. Anyway, look at the code. It's a For Each loop and it enumerates the SelectedItems collection of the ListBox. You can write a foreach loop that enumerates the same property in C#.
-
May 21st, 2007, 08:16 AM
#7
Hyperactive Member
Re: Getting Multiple values from listbox to data base
if you have a listbox with let's say names, you could use the event handler method to retrieve the name that the user selects. Then the other part is to add it to the database. Use a SQL insert statement to do this. It's 2 separate issues here as Jhil said.
Jennifer
-
May 22nd, 2007, 01:24 AM
#8
Thread Starter
Junior Member
Re: Getting Multiple values from listbox to data base
Thanks to both u guys i'll try it out......thaks once again
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
|