khentz 0 Junior Poster in Training

Hi,
Here's the code of my listview,.It's already working well. It have a search box in my form, then if the use type in the search box, the result will display at the listbox. Now, what I want to do is when I choose an item in the listview, the selected items will display in 5 textboxes. And it will also allow me to edit, update or delete the chosen record from database.

the code:

If cmbCategory.SelectedIndex = 0 Then

                strSearch = "SELECT * FROM tblMobileTracking WHERE accountNumber LIKE '" & txtSearch.Text & "%'"
                myConnection.Open()

                cmdAcctNum = New OleDbCommand(strSearch, myConnection)

                objDataReader = cmdAcctNum.ExecuteReader

                If objDataReader.HasRows() Then
                    Try
                        lvwSearch.Items.Clear()

                        While objDataReader.Read
                            Dim lv As New ListViewItem

                            With lv
                                .Text = objDataReader.Item("accountNumber")
                                .SubItems.Add(objDataReader("Assignee"))
                                .SubItems.Add(objDataReader("division"))
                                .SubItems.Add(objDataReader("phoneUnitModel"))
                                .SubItems.Add(objDataReader("handPhoneNumber"))
                            End With
                            lvwSearch.Items.Add(lv)
                        End While
                        myConnection.Close()

                    Catch ex As Exception
                        MsgBox(ex.Message)
                        myConnection.Close()
                    End Try
                Else
                    myConnection.Close()
                End If
            End If
Be a part of the DaniWeb community

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