而与SQL Server建立连接时出现与网络相关型号或实例特定的错误 [英] A network-releated or instance-specific error occurred while establishing a connection to SQL Server

查看:382
本文介绍了而与SQL Server建立连接时出现与网络相关型号或实例特定的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对azurewebsites在同一数据中心交谈SQL Azure数据库的简单MVC网站(使用VS互联网模板)。此时的数据库是公正的内置SimpleMembership提供商。我已经从默认的App_Data MDF文件SQL Azure的切换。它工作正常,但有时过了一段时间,这会给:

I have a simple mvc web site (using the VS internet template) on azurewebsites talking to a SQL Azure database in the same data center. The database at this time is just to do the built-in SimpleMembership Provider. I have already switched from the default App_Data mdf file to Azure SQL. It works fine, but sometimes after a while, it would give:

发生-特定实例的网络相关的或错误而
  与SQL Server建立连接。服务器没有被发现或
  无法访问。验证实例名称是否正确,以及
  SQL Server配置为允许远程连接。 (提供者:SQL
  网络接口,错误:26 - 错误定位服务器/实例
  指定)

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

用长消息:

SQLEx preSS数据库文件自动创建错误:

连接字符串指定本地SQL Server防爆preSS实例
  使用应用程序的App_Data目录中的数据库位置。
  该供应商试图自动创建应用程序
  服务数据库,因为供应商确定数据库
  不存在。下面的配置要求是必要的
  成功检查的应用服务存在
  数据库,并自动创建应用程序服务数据库:

The connection string specifies a local Sql Server Express instance using a database location within the application's App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:

但我的的有使用SQL Server防爆preSS连接字符串!

But I do not have a connection string using SQL Server Express!

立即重新启动该网站不会删除错误。

Restarting the web site immediately does not remove the error.

在不改变任何东西,重新启动该网站十五分钟后放弃:

Without changing anything and restarting the web site 15 minutes later give:

502 - Web服务器,同时充当收到了无效响应
  网关或代理服务器。

有与你正在寻找该页面的问题,而且它不能是
  显示。当Web服务器(同时作为网关或代理)
  联系上游内容服务器,它收到了无效响应
  从内容服务器

There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.

previously,我可以恢复网站回到由VS.刚刚重新publshing工作秩序但对于最后一个小时我已经试了又试,我不能让网站重新工作。

Previously, I could restore the website back to working order by just re-publshing from VS. But for the last hour I have tried and tried and I cannot get the web site to work again.

什么是关于SQL Server防爆preSS真正的问题呢?

我的连接字符串部分包括:

My connection string section contains:

<connectionStrings>
  <add name="DefaultConnection" connectionString="Server=tcp:sabl6h4---.database.windows.net,1433;Database=MVC;User ID=test@sabl6h4---;Password=----;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.SqlClient" />
  <add name="Entities" connectionString="metadata=res://*/Data.Model1.csdl|res://*/Data.Model1.ssdl|res://*/Data.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=sabl6h4---.database.windows.net;initial catalog=MVC;user id=test;password=----;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
 </connectionStrings>

只是可以肯定,我复制​​并粘贴到sabl6h4---.database.windows.net SSMS和使用登录测试连接并完全没有问题打开了数据库。

Just to be sure, I copied and pasted sabl6h4---.database.windows.net into SSMS and connected using login test and it opened the database without problem.

一天后:我创建了一个新的azurewebsite并公布了相同的项目,相同的web.config。它工作正常,没有任何问题。过了几分钟,发生的确切同样的错误!

One day later: I created a new azurewebsite and published the exact same project and same web.config. It works fine without problems. After some minutes, the exact same error occurred!

三个多小时后:一起去吃午餐,回来后,点击浏览器刷新按钮,该网站又到了。我相信,有人在后端打打闹闹的设置。

Three more hours later: Went for lunch, came back, hit the browser Refresh button, and the web site is up again. I am convinced that someone is fooling around with the settings at the back end.

推荐答案

添加&LT;清/&GT; 元素作为的Con​​nectionStrings元素下的第一个元素,以确保没有字符串被继承。另外,我认为你的Azure SQL数据库设置适当的防火墙设置允许您的IP所在的ASP.net code部署?

Add a <clear/> element as the first element under the connectionstrings element to ensure no strings are being inherited. Also, I assume your Azure SQL DB is set up with proper firewall settings allowing your IP where the ASP.net code is deployed?

这篇关于而与SQL Server建立连接时出现与网络相关型号或实例特定的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆