ASP.Net Connection String
Posted on 2014-02-04
I have a connection string in asp.net that controls a drop down in a Grid View. Based on the server that I am on either in Test, QA or Production the Database Instance names are different.
I want to be able to have the Connection String change v/s being hard coded. I tried a Session String but it doesn't like it;
Here is the base of what I have:
<asp:SqlDataSource ID="SQLConnection" runat="server"
ConnectionString = "<%$ ConnectionStrings:DBConfig %>"
SelectCommand = "SELECT Name FROM TableName "></asp:SqlDataSource>
What I want is to be able to replace the DBConfig with something dynamic that will distinguish the different instance names that it looks at in the web.config based on the server name.