I'm using sql dependent caching in my ASP.NET application, and to achieve this I have the following entry in the web.config:
<connectionStrings>
<add name="DatabaseName" connectionString="Data Source=.\Dev;Initial Catalog=DatabaseName;Integrated Security=True" />
</connectionStrings>
<system.web>
<caching>
<sqlCacheDependency enabled="true">
<databases>
<add name="DatabaseName" connectionStringName="DatabaseName"/>
</databases>
</sqlCacheDependency>
</caching>
</system.web>
In the application, a SqlCacheDependency is created using the name of the database that is specified in the web.config, like this:
var tableDependency = new SqlCacheDependency("DatabaseName", "TableName");
What I want to achieve is removing the need for the connection string in the web.config, as this application's connection string is likely to change when placed onto different servers.
There is already a connection string class in the application that returns the correct string for what server it is currently on, so without using that, I will have to manually change the connection string in the web.config on each server.
Thanks in advance,
Greg.