这是我第一次与Oracle合作,而且我们都讨厌在你使用特定模型的同时使用外国产品,尽管这是我们的工作,我们必须做到.
现在我已经安装了Oracle 11g,并复制并引用了Oracle.DataAccess.dll,创建了一个方法,用于打开连接并尝试从服务器上创建的视图中检索某些对象.
方法:
public BindingList GetHeaderReceivers()
{
try
{
using (OracleConnection db = new OracleConnection(BaseDataAccess.ConnString))
{
string cmdText = “select * from p_customer t”;
BindingList headerReceivers = new BindingList();
OracleCommand cmd = new OracleCommand(cmdText) { CommandType = CommandType.Text };
db.Open();
OracleDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (reader.Read())
headerReceivers.Add(HeaderReceiver.GetInstance(reader));
CustBranchRepository rep = new CustBranchRepository();
headerReceivers.ForEach(p => p.DetailsBranch = rep.GetDetailReceivers(p.Id));
reader.Close();
db.Close();
return headerReceivers;
}
}
catch (Exception ex)
{
ExporterLogger.Log(ex);
return null;
}
}
现在,当ExecuteReader()提交时,我得到了这个InvalidOperationException.
Operation is not valid due to the current state of the object.
StackTrace:
at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(CommandBehavior behavior)
at Exporter.Boss.DataAccess.CustomerRepository.GetHeaderReceivers() in …Exporter\Exporter.Boss.DataAccess\CustomerRepository.cs:line 25
任何想法和帮助……
谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/36550.html