Wrox Programmer Forums
| 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 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
  #1 (permalink)  
Old January 5th, 2004, 04:18 PM
Authorized User
 
Join Date: Aug 2003
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with query

I have a search that I am trying to add wildcards to, and when I run it I get this error.

Error:
ADODB.Recordset error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal.

/clearance/postsearch.asp, line 25


When I run it with no wildcards (ie: WHERE exp1 = exp2) it works, but this doesn't seem to be working.


This is the code:


<%@ Language=VBScript %>
<% Option Explicit %>



<%
Dim strtemp, strsearchbox, sql
  Dim objRS
  Dim intnumb

  strsearchbox = Request.Form("searchbox")
  strtemp = Request.Form("searchmenu")
  sql = "SELECT lastname AS Expr1, firstname AS Expr2, alias AS Expr3 FROM Room WHERE " & strtemp & " LIKE '" & strsearchbox & "%'"
  If sql <> "" then
  Set objRS = Server.CreateObject ("ADODB.Recordset")
  objRS.Open sql, objConn
  End If

    Response.Flush

intnumb = 1
If objRS.State = 1 then
    Do while not (objRS.EOF)
        Response.Write "<form method='post' action='addnewPOP.asp' name=alias" & intnumb & ">"
        Response.Write "<input name=hidform type=hidden value='" & objRS("alias") & "'>"
        Response.Write objRS("lastname") & ", " & objRS("firstname") & "(" & objRS("alias") & ") " & "<input type=submit value='Modify' id=submit1 name=submit1></form>"
        Response.Write "<BR>"
        intnumb = intnumb + 1
        objRS.MoveNext
    Loop
End If
    objRS.Close
  %>



  #2 (permalink)  
Old January 5th, 2004, 04:51 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
Default

It's working one way because that way is not returning any records so you aren't hitting the lines that are really causing the problem.

Your SQL select statement:
    SELECT lastname AS Expr1, firstname AS Expr2, alias AS Expr3 ...

Your code:
    objRS("alias")
    objRS("lastname")
    objRS("firstname")

The error is telling you that "alias", "lastname", and "firstname" don't exist in the query results. They don't because you are aliasing them with the "AS Exprx". Remove "AS Expr1", "AS Expr2" and "AS Expr3" and it should work.

Looks like you have been bitten by the Access query sql generator. :)

Peter
------------------------------------------------------
Work smarter, not harder.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query Problem. rupen Access 3 April 27th, 2007 07:43 AM
Query Problem bundersuk VB Databases Basics 0 December 30th, 2006 07:50 AM
problem with query harpua Classic ASP Databases 1 January 24th, 2005 12:36 PM
Problem in query leo_vinay Classic ASP Databases 5 January 21st, 2005 06:32 AM
query problem mateenmohd SQL Server 2000 7 September 9th, 2003 11:58 PM





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