Hi!
When I run this code all the dataadapter is displaying is the first item in my database. None of the other is displayed. I have a database with the following values: ID, Title, Length, Actors, Description, Rating, Genre and Location.
My code looks like this:
Code:Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged Try 'Open connection cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=movies.mdb;") cn.Open() Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter str = "SELECT * FROM moviedata WHERE Title = '" & ComboBox1.Text & "'" da = New OleDb.OleDbDataAdapter(str, cn) da.Fill(ds, "TitleResult") Label2.Text = "Title: " + ds.Tables("TitleResult").Rows(0).Item(1) Label12.Text = "Length: " + ds.Tables("TitleResult").Rows(0).Item(2) + " min" Label13.Text = "Actors: " + ds.Tables("TitleResult").Rows(0).Item(3) Label14.Text = "Description: " + ds.Tables("TitleResult").Rows(0).Item(4) Label15.Text = "Genre: " + ds.Tables("TitleResult").Rows(0).Item(6) Label16.Text = "Location: " + ds.Tables("TitleResult").Rows(0).Item(7) cn.Close() Catch ex As Exception MessageBox.Show(ex.ToString()) End Try End Sub
Also when I try to exit the program I get this error:
"There is no row at Index 0" - Any way to avoid that?
Thanks!




Reply With Quote