An error has occurred while establishing a connection to the server.

Discussion in 'Databases' started by wdarnellg, Mar 26, 2007.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I have an error when I try to run my web app: Following the error copy is a copy of the connection string I am using.


    An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

    Source Error:





    Code:
    Line 1339:            Me.Adapter.SelectCommand = Me.CommandCollection(0)
    Line 1340:            Dim dataTable As Player.PlayerDataTable = New Player.PlayerDataTable
    Line 1341:            Me.Adapter.Fill(dataTable)
    Line 1342:            Return dataTable
    Line 1343:        End Function




    <remove name="LocalSqlServer" />


    <add name="LocalSqlServer" connectionString="Data Source=tcp:sql2k505.discountasp.net;&amp;#xD;&amp;#xA; Integrated Security=false; &amp;#xD;&amp;#xA; Initial Catalog=SQL2005_###_databasename; &amp;#xD;&amp;#xA; User ID=SQL2005_###_correct_user;&amp;#xD;&amp;#xA; Password=password; "


    providerName="System.Data.SqlClient" />

    Post Edited (wdarnellg) : 3/26/2007 1:45:16 AM GMT
     
  2. Is that the only connection string in your web.config?make sure you are not referring to the the local SQL Express server.

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. I removed the reference to the aspnet connection string. But the problem is that my sqldatasources don't work. Do you know of a way to update the configs?
     
  4. I am sure this isn't the optimal solution, but I did a find replace for the connection strings, and the site now works. Can anyone suggest how to rename connection strings?After all, I will need to make improvements.I am new at this, so I know I am doing things the hard way.
     
  5. The imporant thing before changing a connection string name is to make sure that all the references are updated too.

    Lets say you have configured the membership provider to use 'Constring1' as follows:

    - <membership>
    - <providers>
    <clear />
    <add name='AspNetSqlMembershipProvider' type='System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' connectionStringName='Constring1 '</font> ..../>
    </providers>
    </membership>

    If you update Constring1 to Constring2 in the connectionstring section of your web.config ,make sure you update connectionStringName='Constring2' in the above section too.

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page