简体   繁体   English

为什么我的visual studio 2015 SQL Server无法与Azure SQL数据库连接?

[英]Why my visual studio 2015 SQL Server doesn't connect with Azure SQL Database?

I have a SQL Server running on Microsoft Azure. 我有一个在Microsoft Azure上运行的SQL Server。 I want to connect it to My Project in Visual Studio 2015 Community. 我想将其连接到Visual Studio 2015社区中的“我的项目”。 I have added my IP address in firewall on server. 我已经在服务器的防火墙中添加了我的IP地址。 I have also made my port 1433 open for sql. 我还为SQL打开了端口1433。 But when I try to connect to database this error shows up. 但是,当我尝试连接数据库时,会出现此错误。 Error Message in SQL Server SQL Server中的错误消息

It appears that this is a two step process and you either missed the VM configuration or the Azure configuration. 看来这是一个两步过程,您错过了VM配置或Azure配置。 Based on what you said I believe it is the Azure configuration that may have been missed. 根据您所说的,我相信可能遗漏了Azure配置。 This blog post appears to highlight the necessary things that need to be done to connect. 这篇博客文章似乎强调了连接所需的必要操作。

https://blogs.msdn.microsoft.com/ggaurav/2014/01/08/connect-to-sql-database-on-azure-iaas-from-ssms/ https://blogs.msdn.microsoft.com/ggaurav/2014/01/08/connect-to-sql-database-on-azure-iaas-from-ssms/

Below is an excerpt: 以下是摘录:

The two settings which you have to make sure you are checking are : 您必须确保要检查的两个设置是:

  1. Endpoint is configured for the port on which SQL server is listening ( generally 1433) on the VM machine. 为VM机器上SQL Server侦听的端口(通常为1433)配置了端点。

  2. Ports are opened on the VM machine. 在VM计算机上打开了端口。 Even though as per the documentation Cloud adaptor takes care of opening the firewall ports, it doesn't work for the normal connections which you are trying to make. 即使按照文档说明,云适配器负责打开防火墙端口,但对于您尝试建立的常规连接而言,它不起作用。 Just type in ” wf.msc” and create a rule for both outgoing and incoming for TCP port 1433. 只需输入“ wf.msc”,并为TCP端口1433创建一个用于传出和传入的规则。

As soon as you are done with these two, you would be able to connect to the SQL server on the VM machine. 完成这两个操作后,您将能够连接到VM计算机上的SQL Server。

According to your description, I guess your SQL database is a Azure service, not install SQL on Azure VM. 根据您的描述,我猜您的SQL数据库是Azure服务,而不是在Azure VM上安装SQL。
If I understand it correctly, we should check SQL database firewall settings and confirm the name of your database . 如果我理解正确,我们应该检查SQL数据库防火墙设置并确认数据库的名称

The error code means, this error could occur because either the firewall on the server has refused the connection or the server is not configured to accept remote connections. 错误代码表示,可能发生此错误是因为服务器上的防火墙拒绝了连接或服务器未配置为接受远程连接。

We can via Azure Portal to check the firewall settings: 我们可以通过Azure Portal检查防火墙设置:
Make sure the Allow access to Azure Services is ON , And make sure your client IP address have added to the Client IP address list. 确保“ Allow access to Azure Services处于“ 打开”状态 ,并确保您的客户端IP地址已添加到“客户端IP地址”列表中。 在此处输入图片说明

Also we should confirm the name of your database, make sure we are connect to the right SQL database. 另外,我们应该确认您的数据库名称 ,确保我们已连接到正确的SQL数据库。

I have also made my port 1433 open for sql. 我还为SQL打开了端口1433。 But when I try to connect to database this error shows up. 但是,当我尝试连接数据库时,会出现此错误。

You also need to enable 1433 port in Network Security Group which related to your VM. 您还需要在Network Security Group中启用与VM相关的1433端口。 Steps below are for your reference. 以下步骤供您参考。

  1. Find the Network Security Group name which related to your VM in Netowrk interfaces panel. 在Netowrk接口面板中找到与您的VM相关的网络安全组名称。

在此处输入图片说明

  1. Open this NSG, click [Add] button in the Inbound security rules panel 打开此NSG,单击“入站安全规则”面板中的[添加]按钮。

在此处输入图片说明

  1. Add a rule as following. 添加如下规则。

在此处输入图片说明

  1. After that, we could access the database hosted in VM using following server name format. 之后,我们可以使用以下服务器名称格式访问VM托管的数据库。

Server name format. 服务器名称格式。

[IP address/dns name],1433

For example, 例如,

13.81.50.123,1433

暂无
暂无

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

相关问题 无法在Visual Studio 2015中将表添加到SQL Server数据库 - Can't add table to SQL Server database in Visual Studio 2015 与Visual Studio 2015中的SQL Server数据库进行交互 - Interacting with SQL Server database in Visual Studio 2015 Visual Studio 2008无法连接到SQL Server 2008 - Visual Studio 2008 doesn't connect to SQL Server 2008 无法将Visual Studio连接到SQL Server数据库 - Can't connect Visual Studio to SQL Server database 我无法从Visual Studio 2012连接到我的SQL Server 2014数据库 - I can't connect to my SQL Server 2014 database from Visual Studio 2012 在Visual Studio中创建安装文件时,为什么不能连接到SQL Server数据库? - Why can't I connect to the SQL Server database when I create setup file in Visual studio? 在Visual Studio或SQL Server Management Studio中连接到Azure SQL数据库的哪些必要步骤? - Which are necessary steps to connect to an Azure SQL database in Visual Studio or SQL Server Management Studio? 如何使用Visual Studio 2015连接到ASP.NET中的本地SQL Server数据库? - How to connect to a local SQL Server database in ASP.NET using Visual Studio 2015? 当我可以使用具有相同登录名的SQL Server Management Studio进行连接时,为什么我的应用程序不连接到SQL Server数据库? - Why won't my application connect to SQL Server database when I can connect using SQL Server Management Studio with the same login? 如何在Visual Studio 2015中为SQL Server创建数据库关系图? - How to create a database diagram for SQL Server in Visual Studio 2015?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM