Link to home
Start Free TrialLog in
Avatar of jeffreyjseaman
jeffreyjseaman

asked on

ASP.Net Connection String

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.

Thanks
Avatar of rawinnlnx9
rawinnlnx9
Flag of United States of America image

If you are using Visual Studio 2010 or higher what you need is right here:

http://stackoverflow.com/questions/305447/using-different-web-config-in-development-and-production-environment
ASKER CERTIFIED SOLUTION
Avatar of rawinnlnx9
rawinnlnx9
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jeffreyjseaman
jeffreyjseaman

ASKER

Thanks for the suggestion but this will not work for what we are trying to achieve.