0

PLEASE HELP ME, MY CODE IS FOR SEARCHING. YOU WILL FIN THE NAME IN THE COMBO BOX, THEN WHEN YOU PRESS SEARCH ALL THE DATA ABOUT THE TENANT WILL BE RETRIEVED. BUT MY PROBLEM IS, EVEN THOUGH THE TENANT IS IN THE LIST, THE CODE ALWAYS RETURN NOT FOUND. PLEASE HELP ME.. THANKS YOU.

HERE IS MY CODE:

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

  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
            TextBox1.Text = dr.Item("address")
            TextBox2.Text = dr.Item("contact_number")
        Else
            MessageBox.Show("Tenant does not exist!")
        End If

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

        End Sub
2
Contributors
2
Replies
5
Views
4 Years
Discussion Span
Last Post by ms061210
0

I think this:

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 & "'"

should be

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 & "'"
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.