Is it possible to crawl through a database?

In Visual Basic, is it possible to search a database for any results CONTAINING a keyword from a textbox?

  • For example: I have a database with two items in it. Those items could be "Sky", and "Ski", for example. I have a textbox with a "Filter" button beside it. When the button is pressed, I would like for the database grid view to show ALL results that CONTAIN the word(s) in the textbox. Let's say I type "Sk" in the text box. I would like both "Sky" AND "Ski" to be displayed, because they both contain the "Sk" that was typed in the text box. Of course, if I type "Sky" in the text box, only "Sky" should be displayed in the grid view of the database. I have not been able to find a good, simple way to do this, and I know there must be one out there. Example code: The code that I am using is as follows (this one is just an example): Me.ExampleCodeBindingSource.Filter = "ItemName = '" & Me.TextBox1.Text & " ' " This code ONLY displays results in the grid view that match EXACTLY what is in the textbox. Any thoughts on how to find results that CONTAIN the textbox word(s) in them? Thanks!

  • Answer:

    try this Dim Search As String Search = "Sk" Set RECTGL = New ADODB.Recordset RECTGL.Open "Select distinct TANGGAL From HISTORY WHERE TANGGAL like '" & Search & "%'", CN, adOpenDynamic, adLockOptimistic

Ryan at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

instead of using =, use LIKE and the % wildcard. Try this. Me.ExampleCodeBindingSource.Filter = "ItemName LIKE '%" & Me.TextBox1.Text & "%'" The % wildcard means any character (zero or more characters) before and after the text.

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.