在古典ASP中使用存储过程执行..并取得成果 [英] Using Stored Procedure in Classical ASP .. execute and get results
问题描述
我试图解决这一整天,但它似乎并没有为我工作。我想执行一个命令,得到结果返回给一个记录。
问题是两件事情之一:要么我得到一个空的反应或有与我的code的一个问题。我确信,这个命令应该取从DB几行。我加了的Response.Write
内循环,但他们从来没有打印出来。
下面是code:
设置康恩=的Server.CreateObject(ADODB.Connection)
conn.openPROVIDER = SQLOLEDB;数据来源= X; DATABASE = Y; UID = Z; PWD = W;
设置objCommandSec =的CreateObject(ADODB.Command)
随着objCommandSec
设置.ActiveConnection =康恩
.CommandType = 4
.CommandText =usp_Targets_DataEntry_Display
.Parameters.Append .CreateParameter(@ userinumber,200,1,10,i编号)
.Parameters.Append .CreateParameter(@组,200,1,50,ISM)
.Parameters.Append .CreateParameter(@ groupvalue,200,1,50,ismID)
.Parameters.Append .CreateParameter(@ targettypeparam,200,1,50,TARGETTYPE)结束与设置RS =的Server.CreateObject(ADODB.RecordSet)
RS = objCommandSec.Execute
虽然不RS.EOF
回复于(1)
的Response.Write(RS(1_Q1))
rs.MoveNext
WEND
的Response.Write(2)
EDITED
修改code,以下@Joel Coehoorn答案后,解决的办法是:
结果
集RS =的Server.CreateObject(ADODB.RecordSet)
rs.oppen objCommandSec
而不是
结果
集RS =的Server.CreateObject(ADODB.RecordSet)
RS = objCommandSec.Execute
在这个找了几分钟,它一直是一个的长的时间,因为我已经与传统的ASP的工作,但我没有看到三件事情来看待:
- 你需要
打开
之前调用连接objCommandSec.Execute
? - 您可以尝试写一个字符串的循环中文字,这根本不取决于记录...只有你实际上通过code循环,因此看记录回来了记录集。
- 你检查HTML源代码,看看或许畸形的HTML隐藏了的结果?我记得这个情况发生了几次,在传统的ASP循环,其中的数据将被两行,或在错误的地方将结束表结束表标记,后来行之间在某种程度上隐藏不可见的表。
I tried to solve this all day long but it doesn't seem to work for me. I would like to execute a command and get the result back to a recordset.
The problem is one of two things: either I'm getting an empty response or there is a problem with my code. I know for sure that this command should fetch few lines from the DB. I added response.write
inside the loop, but they are never printed.
Here is the code:
Set conn = Server.CreateObject("ADODB.Connection")
conn.open "PROVIDER=SQLOLEDB;DATA SOURCE=X;DATABASE=Y;UID=Z;PWD=W;"
Set objCommandSec = CreateObject("ADODB.Command")
With objCommandSec
Set .ActiveConnection = Conn
.CommandType = 4
.CommandText = "usp_Targets_DataEntry_Display"
.Parameters.Append .CreateParameter("@userinumber ", 200, 1, 10, inumber)
.Parameters.Append .CreateParameter("@group ", 200, 1, 50, "ISM")
.Parameters.Append .CreateParameter("@groupvalue", 200, 1, 50, ismID)
.Parameters.Append .CreateParameter("@targettypeparam ", 200, 1, 50, targetType)
End With
set rs = Server.CreateObject("ADODB.RecordSet")
rs = objCommandSec.Execute
while not rs.eof
response.write (1)
response.write (rs("1_Q1"))
rs.MoveNext
wend
response.write (2)
EDITED
After revising the code, following @Joel Coehoorn answer, the solution is:
set rs = Server.CreateObject("ADODB.RecordSet")
rs.oppen objCommandSec
instead of
set rs = Server.CreateObject("ADODB.RecordSet")
rs = objCommandSec.Execute
Looked at this for a few minutes, and it's been a long time since I've worked with classic asp, but I did see three things to look at:
- Do you need to
Open
the connection before callingobjCommandSec.Execute
? - Can you try writing out a string literal inside the loop, that does not depend at all on the recordset... only that you are in fact looping through the code, so see if records are coming back to the recordset.
- Have you checked the html source, to see if perhaps malformed html is hiding your results? I remember this happening a few times with tables in classic asp loops, where data would be hidden somehow between two rows, or a closing table tag in the wrong place would end the table, and later rows would not be visible.
这篇关于在古典ASP中使用存储过程执行..并取得成果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!