title: Change SQL Server Database Connection Dynamically
body: <p>I have a connection class that I use to connect to my database, every time I do a select, insert, etc... statement. I have the connection string hard coded in the class.</p>
  
  <p>The issue with this is, if I have to change database servers, then I have to change the string on every application, and republish.</p>
  
  <p>Here is my connection string:</p>
  
  <pre><code>var cnnString = string.Format("user id=sa;" +
                                            "password=pw;server=database\\instance;" +
                                            "database=dbase; " +
                                            "connection timeout=10");
  </code></pre>
  
  <p>I thought about creating a table and storing the database info in there, but that doesn't help if can't use the connection class to select from the database.</p>
  
  <p>Is there a way of doing this dynamically?</p>