问题
I am using the following code to perform SQL commands to my azure DB. The I do two calls inside my ASP.NET MVC action method. One to delete from Table A, and the second call to delete from Table B.
using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(ConnectionString))
{
using (System.Data.SqlClient.SqlCommand command = conn.CreateCommand())
{
conn.Open();
command.CommandText = statement;
command.ExecuteNonQuery();
}
}
For whatever reason when I make the second call to this code (I have it in a Helper service class, it bombs with the following Azure error.
Additional information: Login failed for user 'MyUser'.
Is there something I'm not doing correctly but not perhaps closing a connection or something that Azure is having issues with this?
回答1:
You need allow your IP Address to access azure database. click in configure and add your IP.
回答2:
I just needed add to the connection string
Persist Security Info=False;
回答3:
when you publish your project into azure from visual studio, there is a 'settings' tab on the left.
go to the settings. it will show you the connection string that you're using in the web.config.
what worked for me is I unchecked the check box that says 'Use this connection string at runtime (update destination web.config)' and everything went well for me.
来源:https://stackoverflow.com/questions/24510804/sql-server-azure-login-failed-for-user