C#调用oracle存储过程没有返回结果

wlnh 2018-12-13 08:45:24
oracle存储过程如下

CREATE OR REPLACE PROCEDURE P_GETALLDOC( CFLOWSN IN NUMBER, v_rt out sys_refcursor)
AS
BEGIN
open v_rt for
select Flowsn,Attachid as id,attachfile as name from ATTACH where flowsn=CFLOWSN
union all
select flowsn,eformid as id,formname as name from flowforms where flowsn=CFLOWSN;

END P_GETALLDOC;



调用过程如下:

OracleParameter[] paras = new OracleParameter[2];
paras[0] = new OracleParameter("CFLOWSN", OracleType.Number,12);
paras[0].Value = Convert.ToInt32(flowsn);
paras[0].Direction = ParameterDirection.Input;
paras[1] = new OracleParameter("v_rt", OracleType.Cursor);
paras[1].Direction = ParameterDirection.Output;
string connString = ConfigurationManager.AppSettings["ConnString"];

var conn = new OracleConnection(connString);
conn.Open();
OracleCommand oraCmd = new OracleCommand("P_GETALLDOC", conn);
oraCmd.CommandType = CommandType.StoredProcedure;
oraCmd.Parameters.Clear();//先清空
foreach (OracleParameter parme in paras)
{
oraCmd.Parameters.Add(parme);
}
DataTable table = new DataTable();


OracleDataAdapter da1 = new OracleDataAdapter(oraCmd);//取出数据
da1.Fill(table);

//没有记录,实际是有的

if (table.Rows.Count > 0)
{
context.Response.Write("记录:" + table.Rows.Count);
}

...全文
81 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
本人QQ-554433626 2018-12-13
  • 打赏
  • 举报
回复
调用代码应该没问题。 1.存储过程是否在oracle创建,重新编译是否成功 2.调试存储过程查看v_rt值是否有 3.若存储过程测试无值,把sql语句提出执行检查

110,555

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧