我知道这可能是另一个问题的重复,但我已经搜遍了所有内容并尝试了一切,但它似乎仍然给我同样的错误。我们最近从SQL SERVER 2005迁移到2008年。迁移后我们是面对这个问题。我使用的是经典的ASP,SQL和HTML。
以下是我的SQL SERVER 2008程序。我注意到迁移后有一个奇怪的事情,在我的程序中,临时表下面有红线 并警告“无效对象”。但是当我手动运行此程序时,它会返回6条记录
ALTER PROCEDURE [dbo].[SP_ASH_WEB_S] @GMID VARCHAR(10), @DIR_YR CHAR(4)
AS
SET NOCOUNT ON
SELECT DIV_MGR_ID,
'' DMGR_LST_NM,
MGR_ID,
' ' MGR_LST_NM,
SUM(REV_ASG) TOT_ASG,
SUM(REV_HDL) TOT_SVC,
SUM(REV_SLD) CORE_TOT_SLD
INTO #S_GM_AUDIT
FROM
RPT_ASH
WHERE
DIV_MGR_ID = @GMID
GROUP BY
DIV_MGR_ID,
MGR_ID
UPDATE #S_GM_AUDIT
SET DMGR_LST_NM = D.LST_NM,
MGR_LST_NM = M.LST_NM
FROM #S_GM_AUDIT A, ASM M, DSM D
WHERE A.MGR_ID = M.MGR_ID AND
A.DIV_MGR_ID = D.DIV_MGR_ID AND
M.AFF_CD = 'S' AND D.AFF_CD = 'S'
BACKUP LOG FASTRACK TO DISK='NUL:'
SELECT * FROM #S_GM_AUDIT
DROP TABLE #S_GM_AUDIT
这是在调用此过程时给出错误的行;
While NOT ors.EOF
以下是ASP代码
<% Option Explicit
Dim DbObj, SQL, oRs, intRowColor, FNM, GMID, DIR_YR, AFF_CD, YEAR_IND
FNM = Request.QueryString("FNM")
GMID = Request.QueryString("GMID")
DIR_YR = Request.QueryString("DIR_YR")
AFF_CD = Request.QueryString("AFF")
YEAR_IND = Request.QueryString("YEAR_IND")
%>
<% Server.ScriptTimeout = 300 %>
<head>
<meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</head>
<%
IF AFF_CD = "P" THEN
IF YEAR_IND = "N" THEN
SQL = "SP_ASH_WEB_S 'P', '" & GMID & "', '" & DIR_YR & "'"
ELSE
SQL = "SP_ASH_WEB_S'P', '" & GMID & "', '" & DIR_YR & "'"
END IF
END IF
OpenConnection()
Set oRs = DbObj.Execute(SQL)
%>
<form method="get">
<table BORDER="0" WIDTH="100%" cellpadding="0" cellspacing="0">
<%
dim totasg,totsvc,coretotsld,grandtotasg,grandtotsvc,grandcoretotsld
WHILE NOT oRs.EOF
totasg = oRs.Fields("tot_asg")
totsvc = oRs.Fields("tot_svc")
coretotsld = oRs.Fields("core_tot_sld")
grandtotasg = grandtotasg + totasg
grandtotsvc = grandtotsvc + totsvc
grandcoretotsld = grandcoretotsld + coretotsld
if intRowColor = "0" then
intRowColor = "1"
这是我的OpenConnection()
函数的定义:
Function OpenConnection()
Set DbObj = Server.CreateObject("ADODB.Connection")
DbObj.Open "DATABASE=Fastrack;Provider=SQLOLEDB;
DataSource=ASHISH\ASHISH;UID=ashish;PWD=ashish;"
End Function
Function CloseConnection()
DbObj.Close()
set DbObj = nothing
End function