我想知道为什么我不能在ASP.NET web.config文件中使用自定义环境变量?ASP.NET web.config文件中的环境变量
<?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>
我通过开始 - >运行检查到.mdf文件的文件路径是有效的。
当我运行我的C#代码连接到数据库,会出现以下错误:
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.
您使用的备用解决方案是什么? – 2017-01-21 01:47:33