Search database table and display results in listbox using adodc
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
(1(1 Vote))
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
Search database table and display results in listbox using adodc Comments
No comments yet — be the first to post one!
Post a Comment