Search code examples
c#asp.netsql-serverazuresqlconnection

SQL Server Azure "Login failed for User"


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?


Solution

  • You need allow your IP Address to access azure database. click in configure and add your IP.