有这么一段代码,当执行while循环时,循环执行一次后在"while(TempDr.Read())"处报一个错误:Invalid operation. The OracleDataReader is closed. 这是为什么啊??sql = "select s.inst_id,s.inst_name,t.lsparent from pmis.pm_om_insts s ,PM_PD_DEPS t where t.lsparent = 176 and s.inst_id=t.inst_id order by s.inst_dsp_idx";
Conn.Close();
Conn.Open();
OracleCommand TempCom = new OracleCommand(sql,Conn);
OracleDataReader TempDr = TempCom.ExecuteReader();
try
while(TempDr.Read())
{
string strId = TempDr["lsparent"].ToString();
string instid = TempDr["inst_id"].ToString();
GetParentNode(TreeView1.Nodes,strId);//自己定义的函数
string sql1 = "select inst_id,inst_name from pmis.pm_om_insts where inst_id={0}";
sql1 = string.Format(sql1,instid);
InitNode(ParentNode,sql1);//自己定义的函数
}
}
finally
{
//Conn.Close();
}
Conn.Close();
Conn.Open();
OracleCommand TempCom = new OracleCommand(sql,Conn);
OracleDataReader TempDr = TempCom.ExecuteReader();
try
while(TempDr.Read())
{
string strId = TempDr["lsparent"].ToString();
string instid = TempDr["inst_id"].ToString();
GetParentNode(TreeView1.Nodes,strId);//自己定义的函数
string sql1 = "select inst_id,inst_name from pmis.pm_om_insts where inst_id={0}";
sql1 = string.Format(sql1,instid);
InitNode(ParentNode,sql1);//自己定义的函数
}
}
finally
{
//Conn.Close();
}
解决方案 »
- gridview中使用RadioButton
- 请教回车提交!
- 请教MSDN上关于自定义状态管理的一个问题
- 如何将一段html插入到div中光标所在位置?
- 怎么样在ASP.NET实现二级分类
- 散分求客户需求不断变化的问题
- 大家看看这个表格怎么选择?
- ASP.NEt 回车阻止回发求大神
- 异常详细信息: System.InvalidOperationException: Fill:SelectCommand.Connection 属性尚未初始化
- 请教FormsAuthentication的用法
- 各位大俠 當輸入文本框設置為AutoPostbacke的時候如何用驗証控件進行驗証輸入數據的正確性?
- 请高手帮忙?错在那里
不是说得很清楚吗?,已关闭了OracleDataReader
可能是InitNode(ParentNode,sql1)中的某个地方关闭了,不,应该是又重新打开了另一个,Read是要一直保持连线的