Setting to NULL does not Dispose an object - it just removes the reference from use which allows the Garbage Collector to clean it up when it runs - which will only occur normally when the memory in the system starts to run low. As a result, unless you explicitly close (and Dispose) your SqlConnection (and SqlCommand) instances, they remain active, probaboly until your app closes.
The best way to handle this is to use
using
blocks:
using (SqlConnection con = new SqlConnection(strConnect))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("SELECT Id, description FROM myTable", con))
{
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
int id = (int) reader["Id"];
string desc = (string) reader["description"];
Console.WriteLine("ID: {0}\n {1}", id, desc);
}
}
}
}
This will ensure that each object is automatically Closed and Disposed when it goes out of scope.