Parse ASP search string into query string? 
Author Message
 Parse ASP search string into query string?

I want to let users enter keywords into a text box on an ASP page, and then
search several fields in a SQL Server 2000 table for instances of those
keywords.  If there's something already built in SQL Server or ASP/Interdev
to do this, I've missed it in my search and would be grateful to have you
point out my shortcomings.  Otherwise I'm assuming I have to build it.

The function I'm looking for or have to build should ideally accept quoted
strings and Boolean language and output the "WHERE" clause for a query.  For
example, if the user enters

  "red apples" and bananas or oranges

the dreamed-for function will return the string

  "WHERE (((<field1> LIKE %red apples%) AND (<field1> LIKE %bananas%)) _
    OR (<field1> LIKE %oranges%)) OR _
    (((<field2> LIKE %red apples%) AND (<field2> LIKE %bananas%)) _
    OR (<field2> LIKE %oranges%))

Any advice appreciated.  TIA



Fri, 18 Jun 2004 01:16:53 GMT
 Parse ASP search string into query string?

Try this :

          searchstring = split(trim(request.querystring("search")),"+")

           for i=0 to ubound(searchstring)
              sqlstr = sqlstr  &  like '%" & searchstring(i) & "%' "
           next

ciao



Quote:
> I want to let users enter keywords into a text box on an ASP page, and
then
> search several fields in a SQL Server 2000 table for instances of those
> keywords.  If there's something already built in SQL Server or
ASP/Interdev
> to do this, I've missed it in my search and would be grateful to have you
> point out my shortcomings.  Otherwise I'm assuming I have to build it.

> The function I'm looking for or have to build should ideally accept quoted
> strings and Boolean language and output the "WHERE" clause for a query.
For
> example, if the user enters

>   "red apples" and bananas or oranges

> the dreamed-for function will return the string

>   "WHERE (((<field1> LIKE %red apples%) AND (<field1> LIKE %bananas%)) _
>     OR (<field1> LIKE %oranges%)) OR _
>     (((<field2> LIKE %red apples%) AND (<field2> LIKE %bananas%)) _
>     OR (<field2> LIKE %oranges%))

> Any advice appreciated.  TIA



Fri, 18 Jun 2004 01:28:47 GMT
 Parse ASP search string into query string?
You are probably looking for the FULLTEXT-SEARCH capabilities of SQL Server.
You will find in the Books Online documentation the way predicates like
'contains' and 'freetext' work.
You'll also have to decide for the time-interval to update the indexes built
by FTS.

Horea Hopartean
MCP



Fri, 18 Jun 2004 08:30:53 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Parsing to search an apostrophe within a string search field

2. String parsing - Capitalizing each word in a string

3. Parsing a string search field...

4. Parsing a SQL Query String

5. ?? code for PARSING input string for SQL query

6. ORA-04030 out of process memory when trying to allocate string bytes (string,string)

7. P5W: table string like query string??

8. Newbie question - Inserting ASP query string variables

9. search a string with a query

10. Query to search XML for a string

11. Need Help with a Search Query String

12. Search String errors, when querying Index Server via SQL7


 
Powered by phpBB® Forum Software