3

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?

6
  • 1
    What does your connection string look like (remember to blank out personal data)? I bet you are using Windows Authentication and your Sql server does not have a login for the user that the webserver is running as. Commented Jul 1, 2014 at 12:54
  • And what are the commands you are executing? Commented Jul 1, 2014 at 12:58
  • Commands: delete from table1, delete from table2 Commented Jul 1, 2014 at 12:59
  • I just noticed something.. I am pulling the connection string from the Entity Framework Entities class. "MyEntity.Database.Connection.ConnectionString" the second time I call into it the password for the connection string is missing.. why is this? Commented Jul 1, 2014 at 13:01
  • 1
    Do you have Persist Security Info=True? Commented Jul 1, 2014 at 14:33

3 Answers 3

5

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

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

1 Comment

How does one allow firewall access for an App Service? I only get this error in production (no matter what my connection information is in my web config) but the app service doesn't have an IP.
1

I just needed add to the connection string

Persist Security Info=False;

Comments

0

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.

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.