Does CommandBehavior.SingleRow call a database connection to stay open?

I recently worked on a project in VB.NET and I ran into a mysterious problem with some of the DB connections. It was a project that I inherited from someone else, and they used something like this:

Dim reader As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection And CommandBehavior.SingleRow)
//after reading data
reader.Close()

This seems to cause the connection to not close properly all the time. I removed CommandBehavior.SingleRow and it seems to be working fine now, but I was wondering if anyone else came across this? Does anyone know why this will not work? I had seen CommandBehaviors before, but had never done it before.

+3
source share
1 answer

OR :

Dim reader As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection Or CommandBehavior.SingleRow)
+4

Source: https://habr.com/ru/post/1708836/


All Articles