Re: using(SqlConnection = ... ) ?
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 05/27/04
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: Murach's C# book, anyone used it?"
- Previous message: Nicholas Paldino [.NET/C# MVP]: "Re: Indigo/'.NET Framework' vs winsock and more..."
- In reply to: sevenfifteen: "Re: using(SqlConnection = ... ) ?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 27 May 2004 13:34:42 +0100
sevenfifteen <anonymous@discussions.microsoft.com> wrote:
> If you call Close() on an SqlConnection, then that makes it disappear from sp_who2
> or Enterprise Manager. i.e. you're actually telling SQL server that
> you don't want to use that connection any more.
> If you let a using block expire, it doesn't.
> Damn.
It certainly doesn't log out the connection - or at least, it didn't
when I last tried it, looking at SQL Server Profiler. I suggest you use
the profiler to see what happens - I've got a test program in the
.adonet newsgroup from about a week ago asking about the same question.
In fact, I've just tried executing sp_who2 myself with my test program,
after opening and closing a connection 3 times - and I see two sleeping
connections. It's only after the process exits that the connections
drop.
-- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
- Next message: Nicholas Paldino [.NET/C# MVP]: "Re: Murach's C# book, anyone used it?"
- Previous message: Nicholas Paldino [.NET/C# MVP]: "Re: Indigo/'.NET Framework' vs winsock and more..."
- In reply to: sevenfifteen: "Re: using(SqlConnection = ... ) ?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|