[英]ASP.NET Web.Config File Specifying A DataSource ConnectionString
I'm trying to use an 'SQL Express' (or is it SQL Compact?) .MDF file as the datasource on a simple website using a Chart control. 我正在尝试使用'SQL Express'(或者它是SQL Compact?)。MDF文件作为使用Chart控件的简单网站上的数据源。
Locally, it works great; 在当地,它很棒; but only if the 'AttachDbFilename' has the full path.
但仅当'AttachDbFilename'具有完整路径时。 Am I messing something up, or does it really need to be full path?
我搞砸了什么,还是真的需要走完全路? If so - how do I accomplish this without using something like Server.MapPath()?
如果是这样 - 如何在不使用Server.MapPath()之类的情况下实现此目的?
<add name="LocalSqlServer"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
By default, the |DataDirectory| 默认情况下,| DataDirectory | variable will be expanded as follow:
变量将扩展如下:
You can programmatically set DataDirectory by calling AppDomain.CurrentDomain.SetData("DataDirectory", newpath)
您可以通过调用
AppDomain.CurrentDomain.SetData("DataDirectory", newpath)
以编程方式设置DataDirectory
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.