hi
1) I noticed that after you close SqlConnection instance, you are still able to re-open the same connection:
a) can you tell me what is going on behind the scenes? Meaning, after we close file stream object, we can’t re-open it, but instead must create a new object – so why isn’t the same with SqlConnection objects?
b) If pooling is enabled, then I assume the connection object is returned back to the connection pool and can later be reused?!
But then how do we know that after re-opening the connection we will get the same Sqlconnection instance as before we initially closed it? I’m asking this because as far as I know, even if connection pool has several connections available, these SqlConnection objects could be in different state than original SqlConnection object ( by “different state” I mean that some properties could hold different values than those in “original” connection object)?!
c) What if pooling isn’t enabled? Does .Net recreate SqlConnection object “from scratch”? Again, before we initially closed the SqlConnection object, we might have changed values of some properties? How will compiler know how to recreate the state SqlConnection object was in before we closed it?
thank you