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))
            End If

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.

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


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