0

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.

3
Contributors
3
Replies
25
Views
6 Years
Discussion Span
Last Post by sinsarith
0

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
0

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

This question has already been answered. 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.