简体   繁体   English

在Web.config中更改连接字符串以访问本地数据库而不是联机数据库

[英]Changing Connection Strings in Web.config to access local database instead of online database

(sorry if this is a stupid question) I've recently discontinued a site that I created, as well as the online database. (很抱歉,如果这是一个愚蠢的问题),我最近停止了我创建的网站以及在线数据库。

Recently, I've been interested in working on it locally, so I can learn more about web/databases and the like. 最近,我对在本地进行开发很感兴趣,因此我可以了解有关Web /数据库等的更多信息。 The only thing is - I'm not sure how to change the connection string in the web.config from the online connection to the local connection. 唯一的是-我不确定如何将web.config的连接字符串从联机连接更改为本地连接。 I've already copied the database to a local server in SQL Management Server Studio. 我已经将数据库复制到SQL Management Server Studio中的本地服务器。

  • What's the syntax for using a local database as a connection string? 使用本地数据库作为连接字符串的语法是什么?

Here is the old online database connection string: There's two connections both to the same database (from what I gather, one is due to the user login, the other is for model creation from database) 这是旧的在线数据库连接字符串:到同一个数据库都有两个连接(从我收集的数据中,一个是由于用户登录,另一个是从数据库创建模型)

<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient"
connectionString="Data Source=tcp:pokemondaycare.database.windows.net,1433;Initial Catalog=PDC-TESTING;Integrated Security=False;User Id=ServerAdmin@pokemondaycare;Password=AzBanks_1;Encrypt=True;TrustServerCertificate=False;MultipleActiveResultSets=True" />
<add name="pokemonDayCareDatabaseEntities" connectionString="metadata=res://*/Models.PDCDataModel.csdl|res://*/Models.PDCDataModel.ssdl|res://*/Models.PDCDataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=pokemondaycare.database.windows.net;initial catalog=PDC-TESTING;persist security info=True;user id=ServerAdmin;password=AzBanks_1;multipleactiveresultsets=True;application name=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings>

Here is the local database properties 这是本地数据库属性 本地数据库属性

Thanks for any help 谢谢你的帮助

This is how it should be (a sample). 这应该是这样(一个示例)。 Check Documentation for more information 查看文档以获取更多信息

<add name="MovieDBContext" 
   connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Movies.mdf;Integrated Security=True" 
   providerName="System.Data.SqlClient" 
/>

Change Data Source to dot . Data Source更改为dot . or localhost: 或本地主机:

<connectionStrings>
    <add name="DefaultConnection" 
         providerName="System.Data.SqlClient"
         connectionString="Data Source=.;Initial Catalog=PDC-TESTING;
            Integrated Security=False;..." />
</connectionStrings>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM