在使用 VS2010 创建的默认 ASP.NET 项目中,其中 |DataDirectory|放?
我在默认的 web.config 中看到以下连接字符串:
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
我现在想要更改连接字符串,但找不到 |DataDirectory| 在哪里已设置。我知道它指向我的角色根目录下一个名为 App_Data
的文件夹,其中有文件 aspnetdb.mdf
所在的位置。
查看此页面: http://social.msdn.microsoft.com/Forums/en-US/sqlce/thread/dc31ea59-5718-49b6-9f1f-7039da425296/
它声明使用 SetData 方法设置位置;但是我搜索了整个解决方案,但找不到 SetData 调用或对 |DataDirectory|
的另一个引用。它还指出,默认情况下它使用应用程序文件夹;但我知道事实并非如此,因为该文件位于 App_Data 文件夹下。
有什么建议在哪里设置/我应该在哪里调用 SetData 方法来设置它?第一部分非常有帮助,因为这对我来说是个谜:P
谢谢。
I see the following connection string in the default web.config:
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
I'm at the point when I want to change the connection string, but I cannot find where |DataDirectory| is set. I know it's pointing to a folder called App_Data
under the root of my role, where the file aspnetdb.mdf
is located.
Looking at this page: http://social.msdn.microsoft.com/Forums/en-US/sqlce/thread/dc31ea59-5718-49b6-9f1f-7039da425296/
it states that the SetData method is used to set the location; however I searched the entire solution and I cannot find a SetData call, or another reference to |DataDirectory|
. It also states that as a default it uses the application folder; however I know that is not true since the file is located under the App_Data
folder.
Any suggestions where it is set/where I should call the SetData method to set it? The first part is mroe helpful since it's a mystery to me atm :P
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
App_data文件夹用于存储本地数据库,您可以查看此站点以获取信息 项目结构
要设置数据,您可以使用 AppDomain 类:appDomain 类
这个例子可以帮助您轻松理解应用程序域示例
App_data Folder is Used for Storing the Local Database, you can Check this site for information project structure
To set The data, You can use AppDomain class : appDomain class
and this example may help you to understand easily App domain example