Home > front end >  Problems of emergency consult ASP dynamic stored procedure call
Problems of emergency consult ASP dynamic stored procedure call

Time:10-02

The stored procedure, warrior, please have a look at where there is a problem, has been tuned out the results to the ASP,




The SET ANSI_NULLS ON
GO
The SET QUOTED_IDENTIFIER ON
GO



The ALTER PROCEDURE [dbo] [sp_QC_FinanceWageHZ]
@ sMySqlStr nvarchar (2000)=null,
@ sMyFields nvarchar (50)

AS
SET NOCOUNT ON
Declare @ SQL nvarchar (3000)
Set @ SQL='SELECT SUM (' + @ sMyFields +) as myCont FROM QC_FinanceWageHZDetail Where QC_DetailPID IN (SELECT ID FROM QC_FinanceWageHZ Where QC_DelStat=0' + @ sMySqlStr + ') '

The EXEC SP_EXECUTESQL @ SQL

SELECT @ SQL


Direct call at present: RsCount (" myCont "), but shows no results, directly in the SQL stored procedure running without problems,

SQL stored procedure is used, the results come out,
DECLARE @ return_value int

The EXEC @ return_value=https://bbs.csdn.net/topics/[dbo]. [sp_QC_FinanceWageHZ]
@ sMySqlStr=N 'AND (QC_AudStat=1 OR (QC_NodeWork & gt; 0 AND QC_NodeNums=QC_NodeAudStat AND QC_NodeBackStat=0)) ',
@ sMyFields=N 'QC_DetailMoney'

SELECT 'Return Value=@ return_value

GO




How to bring up in the ASP dynamic field calculation results?





CodePudding user response:

The EXEC SP_EXECUTESQL @ SQL
Change
Try the EXECUTE SQL) (@
Stored procedures is by Command objects call you, as long as the return record sets, should be made to.
  •  Tags:  
  • ASP
  • Related