Hi,

I want to populate a dropdownlistwith information from my database, when a selection is made in another dropdownlist

this is the code I want to execute:

VB Code:
  1. Dim myConnection As New OleDBConnection(ConnectionString)
  2.     ' creates a dataset to store the information gained form the database
  3.     Dim DsMembers As Dataset = New DataSet()
  4.     Dim CommandText As String = "SELECT * from tbl_crews WHERE Name= '" & cbo_Crew.SelectedItem.Text & "'"
  5.     Dim myAdapter As OleDBDataAdapter = New OleDBDataAdapter(CommandText, myConnection)
  6.         myAdapter.Fill(DsMembers, "tbl_crews")
  7.  
  8. Dim I as integer
  9.  
  10. try
  11.  
  12.  For I = 0 To DsMembers.Tables(0).rows.count-1
  13.        Dim strtemp as String = DsMembers.tables(0).rows(I).item(0).tostring & " - " & _
  14.        DsMembers.tables(0).rows(I).item(1).tostring
  15.  
  16.        cbo_member.items.add(strtemp)
  17.  
  18.     Next I
  19.     Catch ex as Exception
  20.           lbl_Message.text = ex.ToString()
  21.     Finally
  22.  
  23.     End Try

problem is that I don't know which command to put it under as it doesn't work on:

VB Code:
  1. Sub cbo_Crew_SelectedIndexChanged(sender As Object, e As EventArgs)

and suggestions?
Thanks