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 November 10th, 2003, 05:21 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Input and Search Database

Hi All,

I need serious help(my job is depended upon this). I want to thank you all in advance for all the helps I can get. I am an amateur in ASP programming and I still haven't grasped all the concepts and techniques. Anyway, here are my question.

Task:
I have a form page(Input.asp) with ONE textbox field, named "Incumbent". I want to be able to type in mulitple incumbents names separating each with a comma in this field. When I hit submit, this will INSERT the entered incumbents names into the "IncumbentName" column in an Access database as ONE record.

After that, I will have a search page(Search.asp) to search for incumbents names; If I were to type in any of the incumbent names I have entered(in the input.asp page), I should be able to get a result.

My question is, is this even possible to do?
If not, could you please tell me the most efficent way to accomplish this task?
I was able to get a search-result if I were enter ONLY ONE name(in the input.asp page), but if I enter multiple names in the input.asp page and then do a search, I never get any result. I thought about have multiple fields (incumbent1, incumbent2, incumbent3, etc.) in the Input.asp page, and do the same in Access. But I know this NOT a convenience way of programming. Could any of you experts out there please lend me a hand? Any suggestion, advice, codes, etc. is GREATLY appreciated!!!

Once again, thank you SOOOOOOOOOO VERY MUCH!!!

Leon

 
Old November 10th, 2003, 06:29 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Yes, this is possible.

Basically, there are a few ways to accomplish what you need. If you want to search for one number in the list of multiple numbers, use a LIKE statement in your query, like this:

WHERE IncumbentName LIKE '%" & searchString & "%'"

The % works like a wild card, so it will find a part of a string in a longer string / text.

If you need to search for multiple items, use the Split method (available in ASP VBScript) on the server to split the search string into multiple elements into an array. Then use this array to add a WHERE clause with a LIKE for each statement, like WHERE Something LIKE this AND Something LIKE that etc etc.

You'll need to do a bit of coding to accomplish this but it is possible.

Search sites like www.4guysfromrolla.com, www.asp101.com, msdn.microsoft.com and this forum for more information.

One more thing: if you are going to insert multiple items separated by a comma, IMO it makes more sense to give each item a record. If you later need to join these items on other tables, things will be much easier than storing all your items in a single text column.

Regards and good luck,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to search in database saif44 ASP.NET 2.0 Professional 11 March 8th, 2006 03:33 PM
Search Database bspradeep Classic ASP Databases 1 September 15th, 2004 05:47 AM
Double search using an input text box Karel Access VBA 2 October 25th, 2003 10:29 PM
form input as database name gtmm9 Classic ASP Databases 1 October 21st, 2003 03:12 PM





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