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 February 4th, 2005, 08:18 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default query AND/OR for textboxes

I have 6 textboxes where if I fill them up I want the query to search if either one of them has results found. I have this but it's not working:
Code:
  SQL = "SELECT * FROM bible WHERE "
  SQL = SQL & "text_data LIKE '%" & Keyword & "%' OR "  
  SQL = SQL & "text_data LIKE '%" & Keywordb & "%' OR "
  SQL = SQL & "text_data LIKE '%" & Keywordc & "%' OR "  
  SQL = SQL & "text_data LIKE '%" & Keywordd & "%' OR "
  SQL = SQL & "text_data LIKE '%" & Keyworde & "%' OR "  
  SQL = SQL & "text_data LIKE '%" & Keywordf & "%' AND "
  SQL = SQL & "book_spoke = '" & spoke_number & "'"

iCounter = iCounter + 1
(I would like to know the use of the iCounter since I use it from other examples but don't know why it's there.)

I've tried this too but this gives every record within
"book_spoke = '" & spoke_number & "'"
Code:
  SQL = "SELECT * FROM bible WHERE "
  SQL = SQL & "book_spoke = '" & spoke_number & "'"
  SQL = SQL & " AND ("
  SQL = SQL & "text_data LIKE '%" & Keyword & "%' OR "  
  SQL = SQL & "text_data LIKE '%" & Keywordb & "%' OR "
  SQL = SQL & "text_data LIKE '%" & Keywordc & "%' OR "  
  SQL = SQL & "text_data LIKE '%" & Keywordd & "%' OR "
  SQL = SQL & "text_data LIKE '%" & Keyworde & "%' OR "  
  SQL = SQL & "text_data LIKE '%" & Keywordf & "%'"
  SQL = SQL & " )"
Learning of our true origins.

I feel sorry:

http://www.infowars.com/articles/wor...eknowledge.htm

Foreknowledge of A Natural Disaster
Washington was aware that a deadly Tidal Wave was building up in the Indian Ocean
 
Old February 4th, 2005, 09:10 PM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

This will work in most of the cases for "book_spoke = '" & spoke_number & "'" because if any of the keyword is blank then u will get all records for book_spoke, for specific id.


 SQL = "SELECT * FROM bible WHERE "
  SQL = SQL & "book_spoke = '" & spoke_number & "'"
  SQL = SQL & " AND ("
  SQL = SQL & "text_data LIKE '%" & Keyword & "%' OR "
  SQL = SQL & "text_data LIKE '%" & Keywordb & "%' OR "
  SQL = SQL & "text_data LIKE '%" & Keywordc & "%' OR "
  SQL = SQL & "text_data LIKE '%" & Keywordd & "%' OR "
  SQL = SQL & "text_data LIKE '%" & Keyworde & "%' OR "
  SQL = SQL & "text_data LIKE '%" & Keywordf & "%'"
  SQL = SQL & " )"

Before creating SQL string, check if there is any data in "Keyword". if there is data, then only add in the SQL query..

Hope this helps


Om Prakash





Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding Textboxes RubyRue ASP.NET 1.0 and 1.1 Basics 1 February 18th, 2008 11:13 AM
Two TextBoxes [email protected] ASP.NET 1.0 and 1.1 Basics 5 April 1st, 2006 06:32 AM
textboxes and additions toiletgraffiti C# 4 January 23rd, 2006 11:50 AM
From listbox to 5 textboxes ThomasF VB Databases Basics 1 September 23rd, 2004 05:39 PM
Using Monthview with 2 textboxes eresina Beginning VB 6 0 October 2nd, 2003 08:33 AM





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