hello, i'm doing a searching form, here is my code

Dim con As New OleDbConnection
            Dim cmd As New OleDbCommand
            Dim rd As OleDbDataReader
            con.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Bengkel\Project\db.mdb")
            cmd.CommandText = "SELECT * from Book where authorName like '%" & textsearch.Text & "%'"
            cmd.Connection = con
            con.Open()
            rd = cmd.ExecuteReader
            Do While rd.Read
                Dim lst As New ListViewItem(rd.Item("authorName").ToString)
                lst.SubItems.Add(rd.Item("title").ToString)
                lst.SubItems.Add(rd.Item("dateBook").ToString)
                lst.SubItems.Add(rd.Item("categories").ToString)

                lvList.Items.Add(lst)
            Loop
            con.Close()

then after that i'm double click the 1 of the row in listview and 1 form popup with all data in database. thanks if some one can help me.

Recommended Answers

All 3 Replies

Here is one way of performing that action.

Private Sub lvList_DoubleClick(ByVal sender As Object, ByVal e As EventArgs) Handles lvList.DoubleClick
   If lvList.SelectedItems.Count > 0 Then
      Dim title As String = lvList.SelectedItems(0).SubItems(1).Text

      'Create a new form with a custom constructor taking the title as argument.
      'Then perform any database lookups in that form based on the title.
      Dim frm As New PopUpForm(title)
      frm.ShowDialog
      frm.Dispose()
   End If
End Sub

thanks, i do this on other form(popunform)

Friend Class SearchResult
    Dim con As New OleDbConnection
    Dim cmd As New OleDbCommand
    Dim rd As OleDbDataReader
    Private Sub SearchResult_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        If FormBookSearching.lvList.SelectedItems.Count > 0 Then
            Title.Text = FormBookSearching.lvList.SelectedItems(0).SubItems(1).Text
        End If

        con.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Bengkel\Project\db.mdb")
        cmd.CommandText = "SELECT * from Book where title = '" & Title.Text & "'"
        cmd.Connection = con
        con.Open()

        rd = cmd.ExecuteReader
        Do
            While rd.Read
                Title.Text = rd("title")
                Author.Text = rd("authorName")
                Description.Text = rd("description")
                Categories.Text = rd("categories")

                Price.Text = rd("price")
            End While
        Loop While rd.NextResult


    End Sub
End Class

and it's work

thank you very for your help about how to disply data in textbox from db

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.