**THIS CODE RETRIEVES DATA FROM THE DATABASE. PLEASE HELP ME DEBUG. I AM EXPERIENCING ERROR CALLED INDEXOUTOFRANGE IN: **

HERE IS MY CODE:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click



        'Try

        Dim oradb As String = "Provider=OraOLEDB.Oracle; Data Source=TRAVELMATE-PC/XE;User Id=cj;Password=me;"

        Dim conn As New OleDb.OleDbConnection(oradb)
        conn.Open()
        Dim cmd As New OleDb.OleDbCommand
        cmd.Connection = conn
        cmd.CommandText = "select last_name, first_name, middle_name from tenant where last_name = '" & Me.ComboBox1.Text & "' AND first_name = '" & Me.ComboBox2.Text & "' AND middle_name='" & Me.ComboBox3.Text & "'"
        cmd.CommandType = CommandType.Text
        Dim dr As OleDb.OleDbDataReader = cmd.ExecuteReader()
        If dr.Read() Then
            'Label5.Text = dr.Item("address")
            Label6.Text = dr.Item("contact_number")
        Else
            MessageBox.Show("Tenant does not exist!")
        End If

        dr.Dispose()
        cmd.Dispose()
        conn.Dispose()


       ' Catch ex As Exception
        ' MessageBox.Show("Error while inserting record on table..." & ex.Message, "Insert Records")
        ' Finally




    End Sub

Your select is

select last_name, first_name, middle_name

None of those items is the contact_number. Try changing your select to

select last_name, first_name, middle_name, contact_number
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.