Im doing an application that runs on vb.net using oracle database.
The function that i did is to select 3 combo boxes for the information to come out.
The problem is i can only retrieve the records from the first selectedindex=0 of the ifelse statement and not from the others.
That means if i choose finance & administration, the next combobox will show controlling and accounting and the last combobox will show the first record of the IDM_IDEA_DATA table. When i changed the sec combobox to procurement & logistics, there are no changes.
The form is at my attachments.
Here are my codes:
Private Sub cboDept_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboDept.SelectedIndexChanged
cboSect.Items.Clear()
If Me.cboDept.SelectedIndex = 0 Then
Me.cboSect.Items.Add("CONTROLLING & ACCOUNTING")
Me.cboSect.Items.Add("PROCUREMENT & LOGISTICS")
Me.cboSect.Items.Add("INFORMATION TECHNOLOGY")
cboSect.SelectedIndex = 0
If Me.cboSect.SelectedIndex = 0 Then
Dim conn As OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As New DataSet
Dim da1 As OleDbDataAdapter
Try
'cmd = New OleDbCommand("Select Distinct * From IDM_IDEA_DATA Where SECT='CONTROLLING & ACCOUNTING'", conn)
'Dim dr As OleDbDataReader = cmd.ExecuteReader
'dr.Read()
'Me.lblId.Text = dr("ID").ToString
conn = New OleDbConnection(My.Settings.ConnectionString)
da = New OleDbDataAdapter("Select Distinct SECT, TEAMNAME From IDM_IDEA_DATA Where SECT='CONTROLLING & ACCOUNTING'", conn)
da.Fill(ds, "IDM_IDEA_DATA")
Me.cboTeamName.DataSource = ds.Tables("IDM_IDEA_DATA")
Me.cboTeamName.DisplayMember = "TEAMNAME"
da1 = New OleDbDataAdapter("Select Distinct * From IDM_IDEA_DATA Where SECT='CONTROLLING & ACCOUNTING'", conn)
da1.Fill(DataSet1, "IDM_IDEA_DATA")
Catch ex As Exception
End Try
ElseIf Me.cboSect.SelectedIndex = 1 Then
Dim conn As OleDbConnection
Dim da As OleDbDataAdapter
Dim da1 As OleDbDataAdapter
Dim ds As New DataSet
Try
conn = New OleDbConnection(My.Settings.ConnectionString)
da = New OleDbDataAdapter("Select Distinct SECT, TEAMNAME From IDM_IDEA_DATA Where SECT='PROCUREMENT & LOGISTICS'", conn)
da.Fill(ds, "IDM_IDEA_DATA")
Me.cboTeamName.DataSource = ds.Tables("IDM_IDEA_DATA")
Me.cboTeamName.DisplayMember = "TEAMNAME"
da1 = New OleDbDataAdapter("Select Distinct * From IDM_IDEA_DATA Where SECT='PROCUREMENT & LOGISTICS'", conn)
da1.Fill(DataSet1, "IDM_IDEA_DATA")
Catch ex As Exception
End Try
End If
I really need help on this. Hope u guys can help me out. Thx