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 March 10th, 2004, 05:37 PM
Registered User
 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to boozin
Default problems with passing user input to a query

im trying to create a page which enables a user to search a database. The search page is simple, it contains a text box and a submit button. my problem is, whenever i try to use the user input as a criteria to do the search, it doesnt do anything. here is my sample code:

<%
  Option Explicit
  Dim strConnect
%>





<HTML>
<HEAD>
<TITLE>Search Page</TITLE>
</HEAD>
<BODY>

<%
  Dim strSearch, strCriteria, strsql, objrs, Conn
  strSearch = Request.Form("system")
  'Set Conn = Server.CreateObject("ADODB.CONNECTION")
  Set objRS = Server.CreateObject("ADODB.Recordset")
  'Response.Write strSearch
  strsql = "Select * From SYSTEMS_IN_QA Where SYSTEM ='&strSearch&'"
  objRS.Open strsql, strConnect


  'Response.Write objrs("SYSTEMS")
  Response.Write RecToTable(objrs)
  objRS.Close
  Set objRS = Nothing
%>
</BODY>
</HTML>

The RecToTable is a function that writes the output to a table. When i fun this the only thing i get are the headings or the field names. The value that im looking for or the output does not show up. I need some advice. any help would be much appreciated. Thanks.

AT.
 
Old March 10th, 2004, 05:46 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

strsql = "Select * From SYSTEMS_IN_QA Where SYSTEM ='&strSearch&'"

This is resulting in a search for this literal text: &strSearch&

I imagine what you wanted is this...

strsql = "Select * From SYSTEMS_IN_QA Where SYSTEM ='" & strSearch & "'"

However, that query requires that your search term must match exactly the value in the database. This is probably also not what you want. You can use this instead:

strsql = "Select * From SYSTEMS_IN_QA Where SYSTEM ='%" & strSearch & "%'"

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old March 10th, 2004, 05:56 PM
Registered User
 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to boozin
Default

Peter,

I tried that statement but the only thing i get is the field names inside the table. it doesnt show the values that im looking for.
 
Old March 10th, 2004, 05:59 PM
Registered User
 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to boozin
Default

peter,

im sorry, it actually works. it was my fault. Thank you so much for your help.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Input Date Parameter values preethig Crystal Reports 0 February 28th, 2008 08:39 AM
Oracle connection-passing input to query!! thottufj Pro Visual Basic 2005 1 October 18th, 2007 03:21 PM
Passing an Input Field to a Parameter Query stcraig BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 4 November 6th, 2006 06:06 PM
passing input to a query mirage Access 3 October 23rd, 2003 08:43 AM





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