无法通过SqlConnection连接到Azure数据库 [英] Cannot connect to azure db via SqlConnection

查看:166
本文介绍了无法通过SqlConnection连接到Azure数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个托管在Azure上的web站点,我已经通过SSMS 2012上传我的db到azure,我可以连接到azure服务器和db在SSMS,当我创建一个连接到数据库资源管理器中的数据库,并测试连接

I have a webiste hosted on Azure and I have uploaded my db to azure via SSMS 2012 and I can connect to the azure server and db in SSMS and when i create a connection to the db in Database Explorer and test the connection it says it works fine.

我无法访问azure管理门户中的db的管理部分(我可以为另一个数据库执行此操作,但是当访问该数据库时会出现同样的问题)一个通过网站)

I cannot access the management section for the db in azure management portal (I can do this for another db but I have the same problem when accessing that one via the website as well)

我尝试给登录'ashley'的db_owner特权

I tried giving the Login 'ashley' the db_owner privilege


EXEC sp_addrolemember'db_owner','ashley'

EXEC sp_addrolemember 'db_owner', 'ashley'

并收到此错误


Msg 15151,级别16,状态1,行1
无法更改角色'db_owner',因为它不存在或您没有权限。 p>

Msg 15151, Level 16, State 1, Line 1 Cannot alter the role 'db_owner', because it does not exist or you do not have permission.

这是webconfig文件中的连接

This is the connection in the webconfig file


add name =C:\USERS\USER\DOCUMENTS\VISUAL STUDIO 2012\PROJECTS\ORGANISER\ORGANISER \APP_DATA\CUSTOMER_DB.MDFConnectionString2
connectionString =Server = tcp: {myserver}; Database = C:\Users\User\Documents\Visual Studio 2012\Projects\Organiser\Organiser\App_Data\Customer_db;用户ID = ashley;密码= {mypassword}; Trusted_Connection = False; Encrypt = Tr ue; MultipleActiveResultSets = True;
providerName =System.Data.SqlClient/

add name="C:\USERS\USER\DOCUMENTS\VISUAL STUDIO 2012\PROJECTS\ORGANISER\ORGANISER \APP_DATA\CUSTOMER_DB.MDFConnectionString2" connectionString="Server=tcp:{myserver};Database=C:\Users\User\Documents\Visual Studio 2012\Projects\Organiser\Organiser\App_Data\Customer_db;User ID=ashley;Password={mypassword};Trusted_Connection=False;Encrypt=Tr‌​ue;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" /

和连接字符串i


string Connection = @C:\USERS\USER\DOCUMENTS\VISUAL STUDIO 2012\PROJECTS\ORGANISER\\ \\ ORGANISER \APP_DATA \CUSTOMER_DB.MDFConnectionString2;

string Connection = @"C:\USERS\USER\DOCUMENTS\VISUAL STUDIO 2012\PROJECTS\ORGANISER\ORGANISER\APP_DATA\CUSTOMER_DB.MDFConnectionString2";

我不明白为什么我可以访问SSMS和数据库资源管理器

I cannot understand why I can access the db in SSMS and in database explorer but not when the website is running.

我也是新的Azure,ASP和MSSQL

I am also new to Azure, ASP and MSSQL in general

推荐答案

根据您的帐户配置,您可能需要向azure数据库配置添加允许的端口/ IP范围。
转到数据SQL数据库属性
- 配置
- 允许的IP地址
- 添加您的IP范围

Depending on your account configuration, you may need to add an allowed port/IP range to azure DB configuration. Go to Data "SQL Databases" properties - Configure - allowed ip addresses - Add your IP range

您就可以连接。

这篇关于无法通过SqlConnection连接到Azure数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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