multiple insert from list box using ASP.NEt

I have a form in which I am using a list box control. I select multiple items from the list box and then I want to insert all those items selected in a table.  I am using the following code to do that (which does not work)

 For i = 1 To ListBox1.Items.Count
            If ListBox1.Items(i - 1).Selected = True Then
                'strsub = ListBox1.SelectedItem.Text
                Dim cmd As New OleDbCommand("INSERT INTO table1 (promo_sub_brand)VALUES('" & ListBox1.SelectedItem.Text & "')", New OleDbConnection(conn))
                cmd.Connection.Open()
                cmd.ExecuteNonQuery()
                cmd.Connection.Close()
            End If
        Next

it only takes the first item thats selected and then exits. what do I need to do in order to insert multiple items from a list box.

pratikshahseAsked:
Who is Participating?
 
nayernaguibCommented:
Replace ListBox1.SelectedItem.Text with ListBox1.Items(i-1).Text in the Insert statement.

_______________

  Nayer Naguib
0
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.

All Courses

From novice to tech pro — start learning today.