Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 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 August 27th, 2009, 01:08 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 141
Thanks: 1
Thanked 0 Times in 0 Posts
Default Dynamic SQL execution issue by using IE 7.0

Hello,

I have Windows Vista, and I am running IE 7.0.

In Microsoft SQL Server 2005, I created a stored procedure to be called by Classic ASP 3.0.

I am having an issue;

Stored Procedure:

-- Dynamic SQL server execution

CREATEprocedure [dbo].[usp_Product_Search_Result]
(
@product_ID int= 0,
@product_name varchar(100)=''
)
AS
Declare @strSQL varchar(5000)
Declare @strWhere varchar(5000)
SELECT @strSQL = "SELECT * FROM tblProducts WHERE 1 = 1"

select @strWhere = ""

-- Product_ID
if @product_id > 0
begin
Select @strWhere = @strWhere + " AND Product_ID = " +convert(varchar(20), @product_id)
end

-- Product Name
IFLen(@product_name)<> 0
begin
Select @strWhere = @strWhere + " AND ltrim(rtrim(product_name)) = '" + @product_name + "'"
end
select
@strSQL = @strSQL + @strWhere
Print(@strSQL)
Execute(@strSQL)


ASP:
call commandcon(con, "dbo.usp_Product_Search_Result")

iflen(trim(request(" product_id" ))) > 0 then
cmd.Parameters("@product_id") = cint(trim(request("product_id" )))
endif

Set
rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = adUseClient
rs.CursorType = adOpenDynamic
rs.Open cmd

==============================
It fails. If I don't use Dynamic SQL, then it is fine.

Thank you for your help.

Mustafa
__________________
MCinar

Love all the creatures because of the creator.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic SQL execution issue by using IE 7.0 mcinar Classic ASP Professional 2 August 29th, 2009 10:33 AM
Unsuccessfuly execution of SQL statement in VBA cindyzhou Access VBA 0 January 1st, 2006 10:58 PM
Unsuccessful execution of SQL statement within VBA cindyzhou Pro VB Databases 0 January 1st, 2006 10:55 PM
Performance Issue of Execution bjohnjebastin ASP.NET 1.0 and 1.1 Basics 1 November 14th, 2005 11:18 AM
Execution Plans and IO Statistics in SQL Server bmains ADO.NET 0 March 19th, 2004 10:40 AM





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