Encapsulate your connection string

Posted on

This article provides a helpful tip that I had never thought of before. Put your database connection string in your web.config file as usual. But take it a step further by creating a class that returns the connection string. It’ll be strongly typed, so you can use Visual Studio’s Intellisense to find the setting from your project.

ASP .NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

I love “best practices.”

http://odetocode.com/Articles/345.aspx