Delen via


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