A network-related or instance-specific error occurred while establishing a connection to SQL Server

Programming, error messages and sample code
Please follow these steps to check the problem,
 
1. Double check if connection string is correct.
<connectionStrings>
    <add name="ConnectionString" connectionString="Data Source=***;Initial Catalog=***;User Id=***;Password=***;" providerName="System.Data.SqlClient"/>
</connectionStrings>
2. If you are using asp.net membership and profile, you have to make sure the membership tables and roles are created to your remote database.
 
To create it, run the aspnet_regsql.exe tool, which is found in the [drive:]\WINDOWS\Microsoft.NET\Framework\versionNumber folder
 
e.g. C:\Windows\Microsoft.NET\Framework\v4.0.30319
 
3. Add a <clear/> element as the first element under the connectionstrings element to ensure no strings are being inherited.
 
Then add connection string named LocalSqlServer, which is in the Providers section under AspNetSqlMembershipProvider.
 
  <connectionStrings>
	<clear />
        <add name="ConnectionString" connectionString="Data Source=***;Initial Catalog=***;User Id=***;Password=***;" providerName="System.Data.SqlClient" />
        <add name="LocalSqlServer" connectionString="Data Source=***;Initial Catalog=***;User Id=***;Password=***;" providerName="System.Data.SqlClient" />
  </connectionStrings>
4. Double check 'defaultProvider' and 'connectionStringName' for membership and profile in web.config.
 
<membership defaultProvider="SqlProvider">
      <providers>
        <clear/>
        <add name="SqlProvider" 
          type="System.Web.Security.SqlMembershipProvider" 
          connectionStringName="ConnectionString"
          applicationName="SampleApplication"
          enablePasswordRetrieval="true"
          enablePasswordReset="true"
          passwordFormat="Encrypted"
          requiresQuestionAndAnswer="true" />
      </providers>
    </membership>

    <profile defaultProvider="SqlProvider">
      <providers>
        <clear />
        <add name="SqlProvider"
          type="System.Web.Profile.SqlProfileProvider"
          connectionStringName="ConnectionString"
          applicationName="SampleApplication"
          description="SqlProfileProvider for SampleApplication" />
      </providers>

    </profile>