I was wondering why I cannot use a custom environment variable in an ASP.NET web.config file, for example?
<?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 path to the .mdf file is valid.
When I run my C # code to connect to the database, I get the following error:
An attempt to mount a database with auto-name for the file% MyProjectsFolder% \ WebAppName \ App_Data \ Database1.mdf failed. a database with the same name exists, or the specified file cannot be opened or is located on the UNC shared folder.
source share