Q

How do I create a wildcard search in my database program?

I'm building a SQL database program to search for names or numbers. I know how to get the exact name or number. But I would like to use a wildcard to show everything starting with "the first few letters" or "the first few numbers." I'm using OleDBDataAdapter to access my database. (VB.NET)
Use SQL "LIKE" keyword together with the "%" wildcard. For example: SELECT * FROM authors WHERE fname LIKE 'J%' (will give you John and Jason) SELECT * FROM authors WHERE telephone LIKE '54%' (will give you all lucky authors living in Argentina -- such as myself!)
This was first published in June 2003

Dig deeper on .NET Framework database programming best practices

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close