简体   繁体   English

数据库已从Microsoft SQL Server中删除,为什么?

[英]Database is removed from Microsoft SQL Server, Why?

I created a new Empty website in Visual studio Express 2013. I created an ASP.NET folder: App_Data. 我在Visual Studio Express 2013中创建了一个新的Empty网站。我创建了一个ASP.NET文件夹:App_Data。

Then I went to SQL Server Management Studio. 然后我去了SQL Server Management Studio。 I created a new Database in which I provided the path to the App_Data of the website that I created. 我创建了一个新的数据库,在其中提供了我创建的网站的App_Data的路径。

I named the database "FacebookData" 我将数据库命名为“ FacebookData”

Then I went to Visual studio; 然后我去了Visual Studio。 I found the database in the App_Data folder and also in Server Explorer. 我在App_Data文件夹和服务器资源管理器中找到了该数据库。

I went to Web.config, And under I added 我去了Web.config,并在下面添加了

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

I click Build -> Rebuild Solution 我单击生成->重建解决方案

When I close SQL Server Management Studio, and reopen it again. 当我关闭SQL Server Management Studio时,再次将其重新打开。 The Database named "FacebookData" is missed from the SQL Server Management Studio Databases list!!!. SQL Server Management Studio数据库列表中缺少名为“ FacebookData”的数据库!!!

I still find it in the Visual Studio in App_Data folder and Server Express. 我仍然在Visual Studio中的App_Data文件夹和Server Express中找到它。

If I close and open the SQL Server Management Studio before adding the to the Web.config. 如果关闭并打开SQL Server Management Studio,再将其添加到Web.config。 The Database is still exist in the SQL Server Management Studio. 该数据库仍然存在于SQL Server Management Studio中。 which makes me feel that there is something wrong in the connection string. 这让我感到连接字符串中有问题。

Any clues? 有什么线索吗?

Your connection string says that database should be "attached" to SQL server when application is run. 您的连接字符串表明,在运行应用程序时,数据库应“附加”到SQL Server。 To have it permanently living in SQl server you should just use SQL server management studio to attach it manually, that way it stays attached. 要使其永久存在于SQl服务器中,您应该只使用SQL Server Management Studio手动附加它,以使其保持附加状态。 You also need to change you connection string to 您还需要将连接字符串更改为

"Server=your_sql_server_instance;Database=FacebookData;Integrated Security=True" “服务器= your_sql_server_instance;数据库= FacebookData;集成安全性=真实”

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

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