ASP使用存储过程和更新后选择

时间:2018-01-25 12:19:56

标签: sql asp-classic

我正在使用ASP来执行存储过程。当我在SQL Server Management Studio中运行存储过程时,我得到返回的列,但ASP中没有返回任何内容。

存储过程有点不同,因为它在update语句之后有一个select语句。如果我删除存储过程中的更新语句,则数据将返回到ASP。

这是ASP

<% 'On error resume next %>
<% Session.LCID=2057 %>

<% 

MM_etdocs_STRING = "Provider=SQLOLEDB.1;Persist Security Info=False;Data Source=MSSQL03\Websys;Initial Catalog=Projects;User ID=*****;Password=****;" 

Set rsnew = Server.CreateObject("ADODB.Recordset")
rsnew.ActiveConnection = MM_etdocs_STRING
rsnew.Source="EXEC eacActionTender 7003,'ZlBhH0APGg','EAC\USER',1,'d'"
rsnew.CursorType = 0
rsnew.CursorLocation = 2
rsnew.LockType = 1
rsnew.Open()

response.write rsnew("Status")
'response.write rsnew("auth_decision")

flds = rsnew.Fields.Count %>

<div><br><%response.write(flds)%><br>

这是存储过程

/*    ==Scripting Parameters==

    Source Server Version : SQL Server 2012 (11.0.6607)
    Source Database Engine Edition : Microsoft SQL Server Enterprise Edition
    Source Database Engine Type : Standalone SQL Server

    Target Server Version : SQL Server 2017
    Target Database Engine Edition : Microsoft SQL Server Standard Edition
    Target Database Engine Type : Standalone SQL Server
*/

SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[eacActionTender] 
    @tid INT, 
    @key CHAR(10), 
    @login NVARCHAR(255), 
    @approve BIT, 
    @message NVARCHAR(2000) 
AS
    /*IF EXISTS(SELECT * FROM t_ActionTender WHERE tid=@tid AND keygen=@key AND auth_decision IS NULL)*/
BEGIN
    IF(@approve = 1)
    BEGIN
        UPDATE t_MiniTender 
        SET Sent = 1 
        WHERE [ID] = @tid
    END

    UPDATE t_ActionTender 
    SET auth_login = @login,
        auth_decision = @approve,
        auth_text = @message,
        auth_date = GETDATE() 
    WHERE tid = @tid 
      AND keygen = @key  
      AND auth_decision = NULL

    SELECT 
        Status = 'OK', 
        viewNewMiniTender.*, 
        t_ActionTender.SentTo AS ActionSentTo, 
        t_ActionTender.auth_decision, 
        t_ActionTender.auth_text, 
        t_ActionTender.auth_date 
    FROM 
        t_ActionTender 
    INNER JOIN 
        viewNewMiniTender ON t_ActionTender.tid = viewNewMiniTender.[ID] 
    WHERE 
        t_ActionTender.tid = @tid 
        AND keygen = @key
END
/*ELSE
  BEGIN
    SELECT Status='Error',Val=@approve
  END*/

我已经让用户访问数据库并查看权限,因为我也可以让同事处理这个问题。

任何帮助都将不胜感激。

0 个答案:

没有答案