VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Search database table and display results in listbox using adodc

by zMastaa (2 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 15th March 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Search database table and display results in listbox using adodc

API Declarations


'Listbox as "list1"
'Textbox called "txtSearch"
'adodc as "adodc1"
'edit the database code after recordsource to your need

Rate Search database table and display results in listbox using adodc



List1.Clear
Dim search As String
Dim Clientname As String
search = txtSearch.Text
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * from database-name WHERE [table] LIKE '%" & search & "%'"
Adodc1.Refresh
If Adodc1.Recordset.EOF Then
MsgBox "No record found matching " & search & "!!!"
Else
Adodc1.Recordset.MoveFirst
End If

List1.Clear
Do Until Adodc1.Recordset.EOF
List1.AddItem (Adodc1.Recordset.Fields(1))
Adodc1.Recordset.MoveNext
Loop
If Adodc1.Recordset.EOF And Adodc1.Recordset.RecordCount > 1 Then
MsgBox "Records Found"
End If
End Sub

Download this snippet    Add to My Saved Code

Search database table and display results in listbox using adodc Comments

No comments have been posted about Search database table and display results in listbox using adodc. Why not be the first to post a comment about Search database table and display results in listbox using adodc.

Post your comment

Subject:
Message:
0/1000 characters