构造DbDataReader时带上“CommandBehavior.CloseConnection”参数,则关闭时会自动关闭连接:

dbCommand.ExecuteReader(CommandBehavior.CloseConnection);

否则在关闭DbDataReader时,一定要记得同时关闭相关的DbConnection

相关文章:

  • 2021-08-30
  • 2021-12-03
  • 2021-06-25
  • 2021-06-05
  • 2021-09-29
  • 2021-07-07
  • 2021-07-29
  • 2022-12-23
猜你喜欢
  • 2022-02-12
  • 2022-02-04
  • 2022-12-23
  • 2021-10-19
  • 2021-10-25
  • 2021-11-23
  • 2022-12-23
相关资源
相似解决方案