How to create a searh in a database field?

M

Miguel Dias Moura

Hello,

I need to create a simple search in a web site.

I have an input text where the user writes the words for search.

When it clicks the "search" button a new page will appear with all the
records of the database which TITLE field includes those words.

Well, if this would be just one word i would send that word in the URL
and i would create an SQL filter in the new page...that would be simple.

Anyway, can somebody help me out?

I am working in ASP.Net / VB with Microsoft SQL 2000 database.

Thanks,
Miguel
 
J

Jeff Dillon

Do you want to know how to build the SQL string, or how to pass multiple
words between pages?

For SQL, it might end up looking like

select <fieldlist> from tablename where title like '%word1%' or title like
'%word2%'.

I'm hoping someone else has a routine in mind to parse a variable number of
words into the proper SQL syntax :)

Jeff
 
M

Miguel Dias Moura

Hi,

What I need is to know how to identify the different words in the input
text and pass them to the next page in the URL.

The SQL you mention should work for 2 words...but for more words how it
would be?

The words inserted in the input text might be a number of 1, 2, 3, ...

Thanks,
Miguel
 
J

Jeff Dillon

Yes, I understand there may be more than one word.

I would suggest POST'ing to the next page, instead of a query string. Or
consider using Server.URLEncode for a string of words with spaces in the URL

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top