title: Asp.net website deployed to windows azure not reading the database
body: <p>I deployed an asp.net website to windows azure with an SQL server express database instance from visual studio. The website works fine and I can browse between pages BUT the web pages are NOT READING THE DATABASE. </p>
  
  <p>This is my webconfig file: </p>
  
  <pre><code>&lt;configuration&gt;
    &lt;system.web&gt;
      &lt;customErrors mode="Off"/&gt;
      &lt;compilation debug="true" targetFramework="4.5" /&gt;
      &lt;httpRuntime targetFramework="4.5" /&gt;
    &lt;/system.web&gt;
    &lt;connectionStrings&gt;
      &lt;add name="MyDBConnectionString" connectionString="Data Source=tcp:jpla04vr2g.database.windows.net,1433;Initial Catalog=DBNAME;User Id=myUser@jpla04vr2g;Password=myPass" providerName="System.Data.SqlClient"/&gt;
  &lt;/connectionStrings&gt; 
  </code></pre>
  
  <p></p>
  
  <p>The web site is running fine but is not reading from the database which is also in windows azure deployed at the same time with website in the app data.</p>
  
  <p>The following is the code to login that I use to login. This code was working fine before deployment when the connection string was pointing to the local database in the app data folder: </p>
  
  <pre><code>try
  {
      string con = ConfigurationManager.ConnectionStrings["MyDBConnectionString"].ConnectionString;
      connection = new SqlConnection(con);
      command = new SqlCommand("SELECT AdminId, Firstname, Lastname, Username FROM ADMINISTRATOR WHERE  (Username=@UN OR Email=@EM) AND AdminPassword=@AP");
      command.Parameters.AddWithValue("@UN", (string)txtUserEmail.Text );
      command.Parameters.AddWithValue("@EM", (string)txtUserEmail.Text);
      command.Parameters.AddWithValue("@AP", FixanythingSecrecy.HashPassword(txtUserPassword.Text));
      command.Connection = connection;
      connection.Open();
      command.ExecuteNonQuery();
      reader = command.ExecuteReader(CommandBehavior.CloseConnection);
      if (reader.HasRows)
      {
          while(reader.Read())
          {
              Session.Add("AdminId", reader["AdminId"]);
              Session.Add("Firstname", reader["Firstname"]);
              Session.Add("Lastname", reader["Lastname"]);                        
          }
          Response.Redirect("companies.aspx");
      }
      else
      {
           lblStatus.Text = "User name or password incorrect.";
      }
  }
  catch (Exception ex)
  {
       Response.Redirect("ErrorPage.aspx");
  }
  finally
  {
      command.Connection.Close();
      connection.Dispose();
      command.Dispose();
  }
  </code></pre>
  
  <p>I get an error:</p>
  
  <blockquote>
    <p>System.Data.SqlClient.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)</p>
  </blockquote>