0

I have the following problem when trying to connect from my Web Role instance to the Azure SQL Database:

[SqlException (0x80131904): 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]

My connection string:

metadata=res:///MyModel.csdl|res:///MyModel.ssdl|res://*/MyModel.msl;provider=System.Data.SqlClient;provider connection string='data source=SOMETHING.database.windows.net,1433;initial catalog=DBNAME;User ID=USERNAME@SOMETHING;Password=PASS!;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;'

I have also linked the database with my Web Role and added the allowable IP. I can connect from using SQL Server Management Studio.

Could there be another problem here?

5
  • 1
    Did you check your allowed ip addresses list in the portal? Commented Jul 17, 2013 at 9:36
  • This didn't work. But now it appears that it won't connect in my emulator either. But it connects fine if I run my web application project. Commented Jul 17, 2013 at 9:41
  • Are there any entries in your allowd ip addresses? Commented Jul 17, 2013 at 9:42
  • Yes, my IP and the IP of the web role. I can connect to the database fine in SQL Server Management Studio Commented Jul 17, 2013 at 9:51
  • I'm with haim770. Can you try adding a rule that opens up 0.0.0.0 to 255.255.255.255 AND be sure the Windows Azure Services is set to allowed. See if your web role can see it then. After validation, remove this rule. Commented Jul 17, 2013 at 11:44

1 Answer 1

0

I had to add MultipleActiveResultSets=True into the connection string:

metadata=res:///MyModel.csdl|res:///MyModel.ssdl|res://*/MyModel.msl;provider=System.Data.SqlClient;provider connection string='data source=SERVER.database.windows.net,1433;initial catalog=DBNAME;User ID=USER@SERVER;Password=PASS;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;MultipleActiveResultSets=True'

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

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.