Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Searching Databases


Message #1 by cyandle@c... on Mon, 23 Jul 2001 02:25:01
I have Beginning ASP Databases and it talked about Filling a Select Form 

but nowhere in the book did it tell you how to search a database.  The 

purpose of my database is to display members of the chamber of commerce 

depending on their respective category say like displaying everyone with 

the category "computers."  I know SQL is involved but how does what they 

input in an text box linked to the SQL and the database?  It has been 

awhile since I have played with databases, please HELP.. :)



Casey Yandle

CityLog.com Lead Web Designer
Message #2 by "Ken Schaefer" <ken@a...> on Mon, 23 Jul 2001 19:00:22 +1000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

From: <cyandle@c...>

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

Sent: Monday, July 23, 2001 2:25 AM

Subject: [asp_databases] Searching Databases





: I have Beginning ASP Databases and it talked about Filling a Select Form

: but nowhere in the book did it tell you how to search a database.  The

: purpose of my database is to display members of the chamber of commerce

: depending on their respective category say like displaying everyone with

: the category "computers."  I know SQL is involved but how does what they

: input in an text box linked to the SQL and the database?  It has been

: awhile since I have played with databases, please HELP.. :)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Have an input text box that users can enter a search category, or a select

list that they can select from



Read this page:

http://w3.one.net/~jhoffman/sqltut.htm

which is a good intro to SQL.



Get the variable the user selected using Request.Form("txtFieldName") and

put it into your select query:



strCategory = Replace(Request.Form("txtFieldName"), "'", "''")



strSQL = _

    "SELECT UserNames " & _

    "FROM table " & _

    "WHERE Category = '" & strCategory & "'"



and put the results into a recordset.



Cheers

Ken





Message #3 by cyandle@c... on Fri, 27 Jul 2001 00:31:57
Can you explain the coding a little bit, like which particular part do u change and the part you 

don't touch at all.  Thanks...
Message #4 by cyandle@c... on Fri, 27 Jul 2001 02:07:08
Here is an example of what I am doing:



My textbox is called Category

My WHERE statement needs to include what they enter and also include other conditions...



WHERE Category = 'what they typed' AND WHERE membertypeid = 'Primary' OR membertypeid 

= 'Associate' OR membertypeid = 'Non Dues'



Then it needs to be displayed in a table with each row alternating colors (light blue and 

white) on a new page.



Thanks...
Message #5 by =?iso-8859-1?q?Birgitta=20Dahl?= <birgittadahl@y...> on Fri, 27 Jul 2001 09:21:17 +0200 (CEST)
Well,



 WHERE Category = '" & Request.Form("name") & "'

AND...



Then just loop through the recordset and in the loop

you Xor the variable, or use something like



 if (strCol = "white") then

  strCol = "skyblue"

 else

  strCol = "white"

 end if



/ Danny



 --- cyandle@c... wrote: > Here is an example

of what I am doing:

> 

> My textbox is called Category

> My WHERE statement needs to include what they enter

> and also include other conditions...

> 

> WHERE Category = 'what they typed' AND WHERE

> membertypeid = 'Primary' OR membertypeid 

> = 'Associate' OR membertypeid = 'Non Dues'

> 

> Then it needs to be displayed in a table with each

> row alternating colors (light blue and 

> white) on a new page.

> 

> Thanks...

>




  Return to Index