Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 10th, 2004, 01:39 PM
Registered User
Join Date: Feb 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default searching a database

I am writing some ASP, but I want to code in a search box that will accept a string from the user and retrieve the info from a SQL Server 2000 database with about 8 tables. Do I have to code it on the Sql side, ASP side or both? Wha would the code be?

Reply With Quote
  #2 (permalink)  
Old March 10th, 2004, 03:07 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

This is a pretty broad question.

You'll have to code it in both ASP and SQL. You need a form for the user to enter their search criteria, you'll need ASP to process that form and you'll have to write some SQL to look up the results from all tables you wish to search from.

Work smarter, not harder.
Reply With Quote
  #3 (permalink)  
Old March 10th, 2004, 06:56 PM
Authorized User
Join Date: Jun 2003
Location: , , .
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts

you can create the form pretty fast in HTML you submit the form as POST or GET (your choice) In the page you submit to use Request.QueryString("fieldName") and sned the value to the database.

sample for Form:

<FORM NAME="tempQuery" ACTION="destinationPage.ASP" METHOD="Get">
    <h1>Your Headline</h1>

        I want to search for:<input type="text" NAME="searchString" VALUE="">
        <INPUT type="submit" value="Continue Next">

sample for the destination:
<%option explicit%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

DIM searchString, objCommand, objRS, sqlStrDef
searchString = Request.QueryString("searchString")
    <title> SearchReturn</title>



sqlStrDef= "SELECT field1, field2, field3 FROM tableName WHERE field1 = '" & searchString & "'"
Set objCommand = Server.CreateObject("ADODB.Command")
objCommand.ActiveConnection = strConn
objCommand.CommandText = sqlStrDef
'executing and resetting to Nothing
objCommand.CommandType = adCmdText
Set objRS = objCommand.Execute
Set objCommand = Nothing


RESPONSE.WRITE "<h1>this is your return</h1>
RESPONSE.WRITE field1 & field2 & field3

something like that shoudl work.

WATCHOUT for special characters especially the mean single quote!!!!

... there is always more to learn...
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
searching a database mark jonas MySQL 13 January 19th, 2007 10:01 AM
Searching through a database d5t ASP.NET 1.0 and 1.1 Basics 6 October 27th, 2006 07:10 AM
help with Database searching europhreak Classic ASP Basics 1 February 8th, 2006 07:30 AM
Searching the database...HELP! Zedman BOOK: Beginning ASP 3.0 6 September 30th, 2004 09:52 AM
Searching trough a database toni_montana PHP How-To 2 September 25th, 2004 09:17 AM

All times are GMT -4. The time now is 09:21 AM.

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