Invalid attempt to call FieldCount when reader is closed

后端 未结 5 635
长发绾君心
长发绾君心 2020-12-20 03:45

The error above occurs when I try to do a dataReader.Read on the data recieved from the database. I know there are two rows in there so it isnt because no data actually exis

5条回答
  •  离开以前
    2020-12-20 03:56

    When I got that error, it happened to be a command timeout problem (I was reading some large binary data). As a first attempt, I increased the command timeout (not the connection timeout!) and the problem was solved. Note: while attempting to find out the problem, I tried to listen to the (Sql)connection's StateChanged event, but it turned out that the connection never fall in a "broken" state.

提交回复
热议问题