寻求有关Classic ASP的帮助。我有一个Oracle 8存储过程,它返回Cursor输出。我想在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
如果有任何问题,请查看并告诉我。
答案 0 :(得分:0)
您是收到错误还是没有结果?
如果没有结果,请尝试更改
Do Until rs.BOF Or rs.EOF
到
Do Until rs.EOF
答案 1 :(得分: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
效果很好。
感谢