• I know this is just an example that you presented in the article. So I have a recommedation ( learnt over time).

    When you are working with connections to the database using the command object, I would sincerely recommend the following technique . The following practice will keep the connection pool in better control:

    Instead of myCommand.Open(); or myCommand.Close(); directly

    Use this while opening connections:

        if( myCommand.Connection.State == ConnectionState.Closed)

                myCommand.Open();

     

    Use this while closing connections:

        if( myCommand.Connection.State == ConnectionState.Open)

                myCommand.Close();