473,385 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Database searching

Hi all - total newbie to DB programming, so bear with me....

I am using a Recordset object, and am trying to implement a search, but am
not having luck finding what I need.

I would like to enter a partial name, and seek records that contain that
string, rather than equal it. All I can find for relational operators are
=, <=, >=, >, and <.

How would I go about doing a "contains" search?

Thanks!
Jul 17 '05 #1
3 4507
sql: like *blabla*

Boobbbbbb heeft geschreven in bericht ...
Hi all - total newbie to DB programming, so bear with me....

I am using a Recordset object, and am trying to implement a search, but am
not having luck finding what I need.

I would like to enter a partial name, and seek records that contain that
string, rather than equal it. All I can find for relational operators are
=, <=, >=, >, and <.

How would I go about doing a "contains" search?

Thanks!

Jul 17 '05 #2
"Boobbbbbb" wrote
OK... So I tried to use '*' as wildcards in this program line:
datNLA.Recordset.Seek "=", "*Boo*"
and it does not work. :( Would I have to convert this to a SQL query? If so, how? Again, I'm a total noob to doing this kind of thing in VB.


Assuming you've dim your database and necessary variables used below, then:
(replace the parts in <> with the appropriate info')

Sub SearchDatabase()
'sub to search a database and assign the results to variables.

'Make up the search term:
strSQLString = "SELECT * FROM <table> WHERE <field> LIKE '<search term /
variable>' "

'Search the database with it:
Set rs<yourRecordSetQuery> = db<yourdatabase>.OpenRecordset (strSQLQuery,
dbOpenForwardOnly)

'Assign appropriate variables using returned search results:
While Not rs<yourRecordSetQuery>.EOF

arr<YourArray>[intCount] = rsQuery![<field>]
intCount = intCount + 1

rs<YourRecordSetQuery>.MoveNext

Wend

End Sub
Jul 17 '05 #3
On Sat, 19 Jul 2003 14:39:49 GMT, in comp.lang.visual.basic
"Boobbbbbb" <ar****************@earthlink.net> wrote:
| Hi all - total newbie to DB programming, so bear with me....
|
| I am using a Recordset object, and am trying to implement a search, but am
| not having luck finding what I need.
|
| I would like to enter a partial name, and seek records that contain that
| string, rather than equal it. All I can find for relational operators are
| =, <=, >=, >, and <.
|
| How would I go about doing a "contains" search?


What database are you using?
In Access you can use
SELECT * FROM table WHERE fieldname like '*" & searchtext & "*'";

If mySQL /SQL Server use:
SELECT * FROM table WHERE fieldname like '%" & searchtext & "%'";

---------------------------------------------------------------
jn****@yourpantsbigpond.net.au : Remove your pants to reply
---------------------------------------------------------------
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: donald | last post by:
Hi all, I have a website running asp (about to move to asp.net soon though) which has a list of DVD's I have the various pages I want, last 10, listing, full listing ect, but the one page i can't...
6
by: Tim Mavers | last post by:
I have a series of database objects that represent things such as people, accounts, etc. I have a set of options (boolean) that I need to add to these objects. Normally I would just create a bit...
2
by: Trevor.D.Matthews | last post by:
I need to develop a scheduling app and am having trouble with the database design. I can easily design a table hold appointments with start and finish times, but I always have an issue when it...
7
by: Dan | last post by:
Hi. I'm having a problem with searching a databse entry. I'm new to dotnet and still trying to figure some things out. In order to locate a row in an access databse file .mdb, i am using this...
3
by: jaYPee | last post by:
i am searching a lot of resources in the net that discusses about database programming. i'm still searching on it and would like to received any links that discusses about database programming in...
13
by: Alex Biddle | last post by:
Hey there. I was wondering whether Python had any support out-of-the-box for database functionality, or database-like functionality. For instance a lot of shared hosts have Python installed,...
3
by: vonclausowitz | last post by:
Hi All, I was thinking of creating a table in my database to index all words in the database. That way I can quickly search for one or more words and the index table will return the words and...
3
by: Stephan | last post by:
Hi all, I am new to access and I face the following "issue": I would like to create a database, to which users can upload files (=pdf, doc, xls...). The files shall be stored locally on a...
9
by: ischwartz88 | last post by:
Hi, I am not a computer programmer. I have been learning VBA along the way of making this script. I know Access and SQL. I have a very large database with many tables and queries. My goal is to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.