hi,
I need a help.how can i SEARCH a record in a database using listbox and display the results?? For an example: if i select a destination on the listbox and it will look for the records on database and display it.
im using ms access and adodb connection.Below is my coding for my program

Dim con As New adodb.Connection                  
Dim r As New adodb.Recordset

con.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & App.Path & "\db4.accdb;"

r.Open "SELECT Destination FROM tblFare , con, adOpenDynamic, adLockOptimistic, adCmdTex"

If r.BOF = True Or r.EOF = True Then
   Label7.Visible = True
    Exit Sub
        Else
    Text8.Text = r!Destination
    Text9.Text = r!Fare
    r.Close
    End If

Recommended Answers

All 2 Replies

Isuggest you to use the Adodc controls instead of writing adodc coding. Also, you may use a Listview to show the retrieved data instead of a Listbox, which is more effective. Thereby you will not have any row alignment issues. To get the data from desired table you may use the Filtering codes.

Thank you so much for the idea :)

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.