• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

How to Insert Data from drop-down list into DB?

I have a drop-down list and an Insert button
How can I Insert data that choose from the drop-down list into DB?

Before this I have set the value for the parameter:
lst.setLocation("Place A");

and when I change to:

I have this error:
Method getLocation in type Loc.Location from assembly getLocation does not have an implementation.

Now what should I change to?

2 Solutions
Cola78Author Commented:
private void Button1_Click(object sender, System.EventArgs e)
{  :

this is working..
but the problem is it will only insert the 1st item in the drop-down list regardless which items u select.
how can I make it to insert only the item I select?
U can see this sample

Dim str() As String
Dim selected As String
For i As Integer = 0 To ListBox1.Items.Count - 1
           If ListBox1.Items(i).Selected = True Then
               selected = selected + ListBox1.Items(i).Text
               selected = selected + ","
           End If
       If Not selected = "" Then
           selected = Left(selected, Len(selected) - 1)
       End If
       str = selected.Split(CType(",", Char))

This way u can get a string array containing a list of selected items. U can insert them into the database
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now