What happens to the data reader when you close the associated database connection?

  • The data reader becomes null
  • The data reader is disposed automatically
  • The data reader remains open
  • The data reader throws an exception
When you close the associated database connection, the data reader throws an exception. This is because the data reader relies on the connection to fetch data from the database. Closing the connection while the data reader is still in use results in an exception being thrown to indicate the invalid operation. It's essential to close the data reader before closing the connection to avoid this issue.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *