在OleDbCommand.ExecuteReader()成功运行后,OleDbDataReader.Read()会抛出异常是什么样的事情?
public void ReadSomeData(OleDbDataReader reader)
{
try
{
while (reader.Read())
{
try
{
// Do something cool with my precious data
}
catch (Exception innerException)
{
// I know what kind of errors I'll catch here
}
}
}
catch (Exception outerException)
{
// What kind of errors would I expect to catch here?
}
}
除了调用reader.Close()之外还有什么东西,这可能会导致reader.Read()在第一次通过这个循环成功运行但是会抛出以后的迭代吗?
(作为一项实验,我尝试在调用ExecuteReader()之后通过SQL Management Studio的对象资源管理器窗格中的右键菜单停止数据库,这似乎不会阻止Read()工作)