1

寻求有关经典 ASP 的帮助。我有一个返回游标输出的 Oracle 8 存储过程。我想在 ASP 页面中调用 SP 并通过循环所有结果集行以表格格式显示数据。

这是我尝试过的代码:

Dim conn, cmd, rs 

Set conn = Server.CreateObject("adodb.connection") 

With conn
    .ConnectionString=strConnect
    .Open
End With

Set cmd = Server.CreateObject ("ADODB.Command") 
Set cmd.ActiveConnection = conn 
cmd.CommandText = "Ref_Cursor_Output_Procedure" 
cmd.CommandType = 4 'adCmdStoredProc 

Dim param1 
Set param1 = cmd.CreateParameter ("pid", adInteger, adParamInput) 
cmd.Parameters.Append param1 
param1.Value = 30 

Set rs = cmd.Execute
Do Until rs.BOF Or rs.EOF 
 -- Do something 
 rs.MoveNext 
Loop 

rs.Close 

请看一下,如果有什么问题,请告诉我。

4

2 回答 2

0

你得到一个错误,还是没有结果?

如果没有结果,请尝试更改

Do Until rs.BOF Or rs.EOF

Do Until rs.EOF
于 2013-12-03T13:56:01.597 回答
0

我得到了解决方案:

Dim cn, rs, cmd, param  
set cn = Server.CreateObject( "ADODB.Connection" )
cn.Open Cstr(strConnect)   '"Provider=MSDAORA.1;Data Source=xxxx;User ID=xx;Password=xx"    
set cmd = server.CreateObject ("ADODB.Command")
with cmd
    set .ActiveConnection   = cn
    .CommandText    =  "{call ref_cursor_procedure({resultset 0, t_cursor})}"
    .CommandType    = 1
end with

set rs = server.CreateObject ( "ADODB.Recordset" ) 
set rs = cmd.execute

Set rs = cmd.Execute
Do Until rs.BOF Or rs.EOF 
 -- Do something 
 rs.MoveNext 
Loop 

rs.Close 

它运作良好。

谢谢

于 2013-12-03T15:42:45.567 回答