.NET documentation says: Status property: Bitwise combination of ConnectionState values
So, I think you should check
!myConnection.State.HasFlag(ConnectionState.Open)
instead
myConnection.State != ConnectionState.Open
since a state can have multiple flags.
csname1910 Dec 18 '15 at 14:19 2015-12-18 14:19
source share