0

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.

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)

I tried giving the Login 'ashley' the db_owner privilege

EXEC sp_addrolemember 'db_owner', 'ashley'

and got this error

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.

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;User ID=ashley;Password={mypassword};Trusted_Connection=False;Encrypt=Tr‌​ue;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" /

and the connection string i use to reference this in the code behind

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

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

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

1
  • I used azure Migration wizard to upload my db to the server instead of SSMS and now using the correct server username which needed username@{server} instead of just username to connect! All is working fine now. Thanks Fabrizio Commented Apr 3, 2013 at 21:38

3 Answers 3

1

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

and you'll be able to connect.

Sign up to request clarification or add additional context in comments.

Comments

0

Your connection string is pointing to a local mdf file. Change the Database= to the name you assigned to your db on Sql Azure.

2 Comments

When I use this connection > <add name="customer" connectionString="Server=tcp:{myserver};Database=[customer];User ID=ashley@dmdf78i69g;Password=*******;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.SqlClient" /> Then I get the same problem. in the first string I saved the name of the db with its filepath. Which i know is bad practice but at the time I was just playing around with it. It is like I dont have the right permissions. Firewall rules are set up also Thank You
Login failed for user exception. I have now fixed the problem by using Azure Migration Wizard instead of SSMS. Thank you :)
0

Make sure you are running the T-SQL query in the correct database context, select your user database in dropdown list.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.