I was wondering why can't I use a custom environment variable in an ASP.NET web.config file like so?
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="ConnectionName" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename='%MyProjectsFolder%\WebAppName\App_Data\Database1.mdf';User Instance=true" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
I checked through Start -> Run that the file path to .mdf file is valid.
When I run my C# code to connect to database I get the following error:
An attempt to attach an auto-named database for file %MyProjectsFolder%\WebAppName\App_Data\Database1.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.