Better Late Than Never.....
I’ve had several people ask why I don’t have a blog out there yet. My standard response has always been that I just don’t have enough time (which is true most days) between running my consulting business, training, spending time with my wife and kids, running the http://www.xmlforasp.net website, writing, etc., etc.. However, after reading more and more blogs from a variety of people I’ve come to the conclusion that creating a blog is a great way to help out others (when the blog is technology related….sorry but I don’t have much to offer in the area of self-help J) plus is a great way to track different things that have been worked on.
I don’t know how many times I’ve figured out a solution to an issue only to experience the same issue several months later. The problem is (due to hitting the ripe old age of 34 I guess) I can’t remember how I fixed the original problem sometimes. So, I’m hoping to start blogging about a few of the different things I come across. While I’ll never be the blogger that Sam Gentile is (the guy is amazing), I’ll try to post a few things from time to time that will hopefully be of value to someone out there.
For those dealing with managing multiple connection strings in development, QA, and production environments I’ve recently posted a new code sample to the XML for ASP.NET Developers Website (http://www.xmlforasp.net) titled “Manage Development and Production Database Connection Strings with XML Serialization”. It makes it simple to handle connection strings without renaming web.config files when moving to a different environment or introducing potential human error into the deployment process. The code relies on XML serialization (one of my favorite technologies in .NET) and provides an object named ServerConfigManager that allows server data to be accessed (such as proxy or mail servers), connection strings to be accessed that are dynamically located based upon the server domain, plus more. Here’s an example of using the ServerConfigManager to access connection strings:
static string _Database = "Northwind";
static string _PrimaryConnStr =
ServerConfigManager.GetConnectionString(_Database).Primary;
static string _SecondaryConnStr =
ServerConfigManager.GetConnectionString(_Database).Secondary;
We use it for everything at my contract site and have found the model both easy to use and quite efficient.
The complete code can be downloaded from http://www.xmlforasp.net/CodeSection.aspx?csID=111.