Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 17th, 2004, 06:14 AM
Registered User
 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multiple Keyword Search

Hi Lists,

I hope somebody out there would be able to help with my problem. I have and access database and asp pages that i would like to do a search base on single word, two or more words and phrases but finding some difficulty with it. At the moment i can only do one word search and if i try to do more words it generates an error.

How can i use the code below to search for multiple keywords?

The code i am using is below:

Private Function sqlString(ByVal keyword)
sqlString = "SELECT * FROM qryMetaData "
sqlString = sqlString & "WHERE "
sqlString = sqlString & "((Abstract LIKE '%" & Replace(Keyword, "'", "''") & "%') OR (Title LIKE '% " & Replace(Keyword, "'", "''") & "%')) "

If DataType = "2" then
       sqlString = sqlString & " AND (DATAFORM LIKE '%MapInfo%') "
Elseif DataType = "3" then
      sqlString = sqlString & " AND ((DATAFORM = 'PDF') OR (DATAFORM = 'IMAGE')) "
End if
sqlString = sqlString & "ORDER BY [TITLE] ASC;"
End Function

Any help would be deeply appreciated.
Thank you in advance
 
Old August 17th, 2004, 04:01 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can you explain more on this to help you better.

What is the difficulty you face with it? Is that showing any error? What does Datatype mean in your code there? Is MapInfo a variable/constant? Which part of the query contruction, you are facing difficulty? What is that you are searching for and on which field are you doing that? Is that Title or Abstract?

More questions would arise if the post is very generic not explain where you face the difficulty:)

Cheers!


_________________________
- Vijay G
Strive for Perfection
 
Old September 10th, 2004, 02:34 AM
Registered User
 
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, I want to be able to do the same thing.
I want to let the user enter multiple words to be searched on.

I have got the code working to return one word, but I don't know how to do it for 2 or more words.

I am using asp with an msaccess database.

Thanks for reading, and hope somebody can help.
 
Old September 10th, 2004, 06:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

This could be done a bit easier in SQL server. As you use msaccess, you will have to do that with some extra effort to get something similar to what it result in sql server.

1) Search for the entire keyword entered.
2) Break the entire keyword into separate words from your frontend and construct the query and search for each word that matches.

This can be done in one step or as two steps, but in anyways there would be performance hit on the db.

Hope that explains.
Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Search by Keyword Grafixx01 Access 10 May 31st, 2007 08:59 AM
Want to Search Several Fields for the Same Keyword Eyrehead Access 3 March 16th, 2007 11:08 AM
Keyword search Echo10 Excel VBA 3 April 23rd, 2006 08:10 AM
highlighting the search keyword(s) Adam H-W Classic ASP Basics 2 February 10th, 2004 09:08 AM
XSLT keyword search help adamr415 XSLT 2 November 12th, 2003 08:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.