p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_databases thread: Search Engine


Message #1 by "Matt Besseling" <mattb@h...> on Wed, 19 Jul 2000 13:16:58
I am trying to write code for a search engine in asp. The engine is 

supposed to search through an access database, and display the 

results(duh).



The user can select options, ie. to search by country, theme, date, and 

name.



The point here is that the scripting is a nightmare. I don't really know 

how to put my SELECT statement with the variables from the submitted form. 

I would like it to search by a specific column, chosen by the user in the 

above option list, the variable is called SearchBy. Then, the statement has 

to include a LIKE command, and then the actual search string.



The closest I've come to some sort of answer is a guess at the following

SELECT * FROM tablename WHERE '" SearchBy "' LIKE '" & SearchString & "'"



I haven't actually tested the above code, but I would just like to know if 

it is workable.



Finally, in the results page, I need a way to display the results in sets 

of 10, with links to the next 10 etc. (as search engines are want to do.)

Does anyone know of a link to a nice resource on this?



Thanks

Matt Besseling

Message #2 by =?iso-8859-1?Q?Gonzalo_Ruiz_de_Villa_Su=E1rez?= <gonzalo.ruizdevilla@a...> on Wed, 19 Jul 2000 14:35:09 +0200
Try the next SQL statement with the Replace funcion to prevent errors.



"SELECT * FROM tablename WHERE '" & Replace(SearchBy, "'", "''") &  "' LIKE

'" & Replace(SearchString , "'", "''")& "'"





If you want to display results in sets try reading this article.



http://www.idevresource.com/asp/library/bytesize/recordset.asp





Cheers,



Gonzalo

-----Mensaje original-----

De: Matt Besseling 

Enviado el: miércoles, 19 de julio de 2000 13:17

Para: ASP Databases

Asunto: [asp_databases] Search Engine





I am trying to write code for a search engine in asp. The engine is

supposed to search through an access database, and display the

results(duh).



The user can select options, ie. to search by country, theme, date, and

name.



The point here is that the scripting is a nightmare. I don't really know

how to put my SELECT statement with the variables from the submitted form.

I would like it to search by a specific column, chosen by the user in the

above option list, the variable is called SearchBy. Then, the statement has

to include a LIKE command, and then the actual search string.



The closest I've come to some sort of answer is a guess at the following

SELECT * FROM tablename WHERE '" SearchBy "' LIKE '" & SearchString & "'"



I haven't actually tested the above code, but I would just like to know if

it is workable.



Finally, in the results page, I need a way to display the results in sets

of 10, with links to the next 10 etc. (as search engines are want to do.)

Does anyone know of a link to a nice resource on this?



Thanks

Matt Besseling



Message #3 by Kent Tegels <kent@t...> on Wed, 19 Jul 2000 07:51:19 -0500 (CDT)
Are you writing this as a stored proc or in-line code. If its inline, you

could do:



strSQL = "SELECT * FROM table WHERE " & request("searchby") " CONTAINS " &

request("searchstring")



The other part of your question would require a page record set. I'm sure

there's examples in MSDN for those... someplace... :)



kt



On Wed, 19 Jul 2000, Matt Besseling wrote:



> I am trying to write code for a search engine in asp. The engine is 

> supposed to search through an access database, and display the 

> results(duh).

> 

> The user can select options, ie. to search by country, theme, date, and 

> name.

> 

> The point here is that the scripting is a nightmare. I don't really know 

> how to put my SELECT statement with the variables from the submitted form. 

> I would like it to search by a specific column, chosen by the user in the 

> above option list, the variable is called SearchBy. Then, the statement has 

> to include a LIKE command, and then the actual search string.

> 

> The closest I've come to some sort of answer is a guess at the following

> SELECT * FROM tablename WHERE '" SearchBy "' LIKE '" & SearchString & "'"

> 

> I haven't actually tested the above code, but I would just like to know if 

> it is workable.

> 

> Finally, in the results page, I need a way to display the results in sets 

> of 10, with links to the next 10 etc. (as search engines are want to do.)

> Does anyone know of a link to a nice resource on this?

> 

> Thanks

> Matt Besseling

> 

Message #4 by Kent Tegels <kent@t...> on Wed, 19 Jul 2000 07:58:32 -0500 (CDT)
Good Answer!



On Wed, 19 Jul 2000, [iso-8859-1] Gonzalo Ruiz de Villa Su=E1rez wrote:



> Try the next SQL statement with the Replace funcion to prevent errors.

>

> "SELECT * FROM tablename WHERE '" & Replace(SearchBy, "'", "''") &  "' LI

KE

> '" & Replace(SearchString , "'", "''")& "'"

>

>

> If you want to display results in sets try reading this article.

>

> http://www.idevresource.com/asp/library/bytesize/recordset.asp

>

>

> Cheers,

>

> Gonzalo

> -----Mensaje original-----

> De: Matt Besseling

> Enviado el: mi=E9rcoles, 19 de julio de 2000 13:17

> Para: ASP Databases

> Asunto: [asp_databases] Search Engine

>

>

> I am trying to write code for a search engine in asp. The engine is

> supposed to search through an access database, and display the

> results(duh).

>

> The user can select options, ie. to search by country, theme, date, and

> name.

>

> The point here is that the scripting is a nightmare. I don't really know

> how to put my SELECT statement with the variables from the submitted form

=2E

> I would like it to search by a specific column, chosen by the user in the

> above option list, the variable is called SearchBy. Then, the statement h

as

> to include a LIKE command, and then the actual search string.

>

> The closest I've come to some sort of answer is a guess at the following

> SELECT * FROM tablename WHERE '" SearchBy "' LIKE '" & SearchString & "'"

>

> I haven't actually tested the above code, but I would just like to know i

f

> it is workable.

>

> Finally, in the results page, I need a way to display the results in sets

> of 10, with links to the next 10 etc. (as search engines are want to do.)

> Does anyone know of a link to a nice resource on this?

>

> Thanks

> Matt Besseling

>

>

> ---

> ---

> You are currently subscribed to asp_databases

> To unsubscribe send a blank email to leave-asp_databases-3319D@p...

om

>



Message #5 by "Ken Schaefer" <ken.s@a...> on Thu, 20 Jul 2000 11:19:39 +1000
Function fncReplaceQuotes(byRef strToReplace)

    fncReplaceQuotes = Replace(strToReplace, "'", "''")

End Function



strTableName = Request.Form("txtTableName")

strSrchTerm = Request.Form("txtSearchTerm")

strSrchTerm = fncReplaceQuotes(strSrchTerm)



strSQL = "SELECT field1, field2, field3 "

strSQL = strSQL & "FROM " & strTableName & " "

strSQL = stRSQL & "WHERE strTableName LIKE '%" & strSrchTerm & "%'"



HTH



Cheers

Ken



----- Original Message -----

From: "Matt Besseling" 

To: "ASP Databases" <asp_databases@p...>

Sent: Wednesday, July 19, 2000 1:16 PM

Subject: [asp_databases] Search Engine





> I am trying to write code for a search engine in asp. The engine is

> supposed to search through an access database, and display the

> results(duh).

>

> The user can select options, ie. to search by country, theme, date, and

> name.

>

> The point here is that the scripting is a nightmare. I don't really know

> how to put my SELECT statement with the variables from the submitted form.

> I would like it to search by a specific column, chosen by the user in the

> above option list, the variable is called SearchBy. Then, the statement

has

> to include a LIKE command, and then the actual search string.

>

> The closest I've come to some sort of answer is a guess at the following

> SELECT * FROM tablename WHERE '" SearchBy "' LIKE '" & SearchString & "'"

>

> I haven't actually tested the above code, but I would just like to know if

> it is workable.

>

> Finally, in the results page, I need a way to display the results in sets

> of 10, with links to the next 10 etc. (as search engines are want to do.)

> Does anyone know of a link to a nice resource on this?

>

> Thanks

> Matt Besseling






  Return to Index