简体   繁体   English

如何在C#中从Oracle存储过程获取数据集值

[英]how to get dataset value from store procedure for oracle in c#

my sp returning table in curser but im getting error while mapping with dataset 我的sp在curser中返回表,但是在与数据集映射时出现错误

DataSet ds = new DataSet();

command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("Size", OracleDbType.Int16).Value = size
command.Parameters.Add("Index", OracleDbType.Int16).Value = Index;
command.Parameters.Add("Data", OracleDbType.RefCursor).Direction = ParameterDirection.Output;

OracleDataAdapter da = new OracleDataAdapter(command);
da.Fill(ds);
return ds;

But I am getting below error: 但我得到以下错误:
How to map it 如何映射

[InvalidOperationException: Operation is not valid due to the current state of the object.] System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e) +130 System.Web.UI.Page.RaiseChangedEvents() +105 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3572 [InvalidOperationException:由于对象的当前状态,操作无效。] System.Web.UI.WebControls.ListControl.OnSelectedIndexChanged(EventArgs e)+130 System.Web.UI.Page.RaiseChangedEvents()+105 System.Web .UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)+3572

[InvalidOperationException: Operation is not valid due to the current state of the object.] [InvalidOperationException:由于对象的当前状态,操作无效。

There are multiple possibilities for this exception. 此异常有多种可能性。

1) command.CommandText = *Your Sp's name will go here*; 1) command.CommandText = *Your Sp's name will go here*; Looks like missing in your code. 看起来像您的代码中缺少。 Give CommandText if missing. 如果缺少,请提供CommandText。

2) In may be because of MaxHttpCollection setting in web.config. 2)中可能是由于web.config中的MaxHttpCollection设置。 By default it can hold 1000. Add following setting in your web.config. 默认情况下,它可以容纳1000。在web.config中添加以下设置。

<appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="2001" />
</appSettings> 

Hope this will solve your problem. 希望这能解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM