存储过程在直接调用时有效,但不能从网站执行

时间:2018-04-11 14:17:56

标签: sql-server xml stored-procedures

我在SQL Server Express 2014中有以下存储过程(显示为“alter procedure”语句)。如果我直接运行它“执行存储过程”,它运行正常并将数据插入weatherdata。如果我远程运行它,插入不起作用。我没有收到任何错误消息。其他一切正常,我有一个类似的存储过程,从file.xml上传到wsdatatemp。它们将是一个存储过程,但已拆分它们以隔离问题。

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[fivedayforecast2]   
AS 
BEGIN 
    SET NOCOUNT ON 

    DECLARE @XML AS XML, @hDoc AS INT, @SQL NVARCHAR (MAX)

    SELECT @XML = XMLData FROM energymaplocs.dbo.wsdatatemp

    EXEC sp_xml_preparedocument @hDoc OUTPUT, @XML;

    INSERT INTO energymaplocs.dbo.weatherdata ([ws_id], [windspeed], [winddirection],[ws_mins], [ws_date])
        SELECT *
        FROM OPENXML(@hDoc, 'SiteRep/DV/Location/Period/Rep',2)
        WITH 
            (ws_id int '../../@i',
             windspeed int '@S',
             winddirection [varchar](3) '@D',
             ws_mins int '@myrep',
             ws_date datetime '../@value'
            )

    --EXEC sp_xml_removedocument @hDoc
END 

所以,上面从SQL Server Management Studio运行时运行正常但是如下所示调用时,似乎运行时没有任何错误但是没有使用插入填充weatherdata

set conn = Server.CreateObject("ADODB.Connection")
set rs = Server.CreateObject("ADODB.recordset")

conn.Open strConnection

sql2 = "exec energymaplocs.dbo.fivedayforecast2"    
set rs = conn.execute(sql2)

rs.close
conn.close

0 个答案:

没有答案