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

  • 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 – user2241161 Apr 03 '13 at 21:38

3 Answers3

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.

sqlandmore.com
  • 163
  • 1
  • 8
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.

Fabrizio Accatino
  • 2,284
  • 20
  • 24
  • When I use this connection > 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 – user2241161 Apr 03 '13 at 19:36
  • Login failed for user exception. I have now fixed the problem by using Azure Migration Wizard instead of SSMS. Thank you :) – user2241161 Apr 03 '13 at 21:39
0

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

Alex Feng
  • 41
  • 1
  • 3