This may be my misunderstanding, but I have a big problem. Please consider the following code:
static void Main(string[] args)
{
using (SqlConnection con = new SqlConnection(connectionString))
{
con.Open();
int i = 10;
con.Close();
con.Dispose();
}
int y = 10;
}
On the line, int y = 10place a breakpoint.
Now go to your SQL Server and right-click on SQl Connection, which is the same connection as connectionStringin the above code, and select "Activity Monitor". Run the above code and check the SQL Server Activity Monitor. When con.Open()executed, the activity monitor indicates that the connection is complete. So far, so good! But when the cursor hits the line indicating int y = 10;Activity Activity Monitor will show you a connection that shouldn't be! Because I closed it, I deleted it and even passed the using statement.
- , ?