ADO.NET Tips….

Tim Sneath has some great ADO.NET Tips. Here are a few of my own:

  • Always close database connections. Yes, even in a GC world.
  • Always approach database connections as a limited resource. You should apply the concept of “acquire late, release early“. In other words, open the connection as late as possible and close it as early as possible. This is one concept that will help you and your application make use of connection pooling.
  • Use connection pooling whenever possible. Connection pooling is a built-in provided that all of the connections in your application make use of the same connection string. When I say “same connection string“, I mean exactly the same - even an extra space in a connection string will cause it to create its own pool.
  • Make use of the encryption libraries in the .NET Framework and encrypt your connection string. More info on this here.


Comments (5)
  1. DonXML says:

    I’ve release a connection string encryption class on GotDotNet. You can find out more via my blog entry:

    or just go directly to the GDN sample:


  2. Alex Lowe says:

    Awesome, thanks Don!

  3. Travis says:

    Does pooling work with SQL Authentification connection strings?

  4. Alex Lowe says:

    Yes, I believe connection pooling will work with all types of authentication.

Comments are closed.

Skip to main content