Okay, So I have a Listbox that contains information from a Database. What I'm doing is selecting rows in that listbox, and then updating the database information for those rows. Then it should refresh the listbox and redraw it without those items that were selected. I thought I had this working before, but when I came back to it today, it didn't work. Here is my code for loading the listbox. This is called at the form load and after the database is updated.
However, once this code executes the items remain in the listbox, even though the database has been updated. Any ideas?
VB.NET:
Private Sub LoadListBox()
Me.lstMovies.DataSource = Nothing
Me.lstMovies.Items.Clear()
conn.ConnectionString = My.Settings.gcstrConnection
strSQL = "SELECT Movie_ID, Title FROM Movies WHERE Status = 'out';"
cmd = conn.CreateCommand
cmd.CommandText = strSQL
conn.Open()
da.SelectCommand = cmd
Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(da)
da.Fill(dsMovies, "Movies")
conn.Close()
conn.Dispose()
cmd.Dispose()
Me.lstMovies.DataSource = dsMovies.Tables("Movies")
Me.lstMovies.DisplayMember = "Title"
Me.lstMovies.ValueMember = "Movie_ID"
Me.lstMovies.Refresh()
My.Application.DoEvents()
End Sub
However, once this code executes the items remain in the listbox, even though the database has been updated. Any ideas?