[英]Unable to find where my database file and connection string is located?
i downloaded a demo application from http://code.msdn.microsoft.com/Authorization-based-aa2c0185/view/SourceCode 我从http://code.msdn.microsoft.com/Authorization-based-aa2c0185/view/SourceCode下载了演示应用程序
I run it on my Visual Studio and all worked fine. 我在Visual Studio上运行它,一切正常。 There is a database
ASPNETDB.MDF
in its App_Data
folder which is used to store the user information or retrieve information for login purpose. App_Data
文件夹中有一个数据库ASPNETDB.MDF
,该数据库用于存储用户信息或检索信息以用于登录。
Now what I want is to change this database with another database in my SQL Server. 现在,我想用我的SQL Server中的另一个数据库更改此数据库。
For that there can be two ways : 为此,可以有两种方法:
Locate the connection string etc. for ASPNETDB
and change them with my own database. 找到
ASPNETDB
的连接字符串等,并使用我自己的数据库进行更改。
or add this ASPNETDB
file to SQL Server by attaching. 或通过附加将该
ASPNETDB
文件添加到SQL Server。 But its showing error while attaching it. 但是在附加时显示错误。
Also if I exclude App_Data
folder from project...Then even it works... 另外如果我从项目中排除
App_Data
文件夹...那么它甚至可以工作...
Where can find connection string for DB? 在哪里可以找到DB的连接字符串? I want to change the DB with mine own ?
我想用自己的数据库更改数据库吗?
Please Help 请帮忙
Thanks 谢谢
它使用来自machine.config的默认连接字符串:
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
Go to the Web.debug.config
file. 转到
Web.debug.config
文件。 There you will find comments noting how to wire up your config file. 在这里,您会发现注释,说明如何连接配置文件。 This will use config transforms so that when you build in debug mode, it will change your config file to override the machine defaults (which is what it is currently using).
这将使用配置转换,以便在调试模式下构建时,它将更改您的配置文件以覆盖计算机的默认值(这是当前使用的默认值)。 Just follow the comments and you should be good :)
只要按照评论,你应该很好:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.