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 December 28th, 2004, 12:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default advance search with stored procedure

Hello, can somebody please help me here. I cannot figure it out or find any information on how to create an advanced search. I have a form with the 3 options of searching for a PrintBuyer, ProjectNumber, or ProjectTitle. I am getting the following error when I do not select the option of PrintBuyer.

ADODB.Command error '800a0d5d'
Application uses a value of the wrong type for the current operation.
searchresults.asp, line 51

If I understand what is happening here is that the the SP is grabbing the ProjectNumber instead, how can I resolve this? If I do test the strPrintBuyer with an IF statement I get, basically the same error.

Microsoft OLE DB Provider for SQL Server error '80040e07'
Error converting data type varchar to int.
searchresults.asp, line 57

Now if I do select a PrintBuyer it will pull up all of my records, but if I add something to the ProjectNumber or ProjectTitle, it will not find any information.


Set objCmd = Server.CreateObject("ADODB.Command")
    With objCmd
        .ActiveConnection = strConnect
        .CommandText = "sp_SelectProject"
        .CommandType = adCmdStoredProc
        .Parameters.Append .CreateParameter("@strPrintBuyerID", adInteger, adParamInput, , strPrintBuyer)
        .Parameters.Append .CreateParameter("@strProjNo", adVarChar, adParamInput, 50, strProjNo)
        .Parameters.Append .CreateParameter("@strProjTitle", adVarChar, adParamInput, 50, strProjTitle)
        .Parameters.Append .CreateParameter("@strOrderBy", adVarChar, adParamInput, 50, strOrderBy)
        Set objSelect = .Execute
    End With

Set objCmd = Nothing


CREATE PROCEDURE sp_SelectProject
(
@strPrintBuyerID int,
@strProjNo varchar (50),
@strProjTitle varchar (50),
@strOrderBy varchar (50)
)
AS
SELECT ProjID, PrintBuyerID, ProjDate, ProjNo, ProjTitle, ProjOtherInfo
FROM Projects
WHERE PrintBuyerID = @strPrintBuyerID
AND ProjNo LIKE @strProjNo%
AND ProjTitle LIKE @strProjTitle%
ORDER BY
CASE WHEN @strOrderBy='ProjDate' THEN Proj_Date
WHEN @strOrderBy='ProjNo' THEN Proj_No
WHEN @strOrderBy='ProjTitle' THEN Proj_Title
END

Many Thanks
Mike Moore
__________________
Peace
Mike
http://www.eclecticpixel.com
 
Old December 29th, 2004, 04:02 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sureshbabu Send a message via Yahoo to sureshbabu
Default

Hi,
 please check the data types ofinput values you are sending to the database whether these are matching the data types of data base fields.
Thanks
Suresh






Similar Threads
Thread Thread Starter Forum Replies Last Post
Bugbase Search Stored Procedure johncross912 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 5 August 22nd, 2007 12:51 AM
Stored Procedure muthu555 SQL Server 2000 1 March 5th, 2007 07:13 AM
Fulltext Search Stored Procedure. maulik77 SQL Server 2000 0 December 28th, 2006 11:52 PM
Advance search recordset giving error message? yts007 Dreamweaver (all versions) 15 January 13th, 2006 01:54 AM
please help me with this stored procedure bebeko SQL Server 2000 1 June 10th, 2005 12:09 PM





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