I can use GetHashCode() to identify an object but is there any way to identify the actual sql connection obtained by a SqlConnection object?
I'm (still) trying to debug a problem involving pooled connections and application roles and if I could reliably identify the underlying sql connection it could help a lot.
Here's some code that might illustrate the question
SqlConnection c = new SqlConnection(myConnString);
c.Open(); // GetHashCode == "X"
c.Close(); // returns connection to pool
c.Open; // GetHashCode() == "X" but possibly different pooled connection?
As I write this question it occurs to me that what I probably want is the SPID of the connection. Sadly, SPID isn't available when the connection is dropped by SQL due to the bug I'm trying to resolve (so at the point I'm most interested in I can't run a command on that connection to obtain the SPID).
Any other bright ideas?