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

Posted on 2007-08-07
Last Modified: 2013-11-27
I'm using VWD Express 2005 which uses sql server 2005.  Web site works fine on local host but when I use FTP to copy to server (a shared server at I get this error message when I try to open a page which requires database interaction in my browser.  (see it at  I have gone into sql server 2005 and configured it for local and remote connections instead of local connections but still no luck.  I believe the problem has to do with the connectionstringname in the web.config file but I don't know why.  Something to do with "LocalSqlServer" ?

<configuration xmlns="">
  <add name="ASPNETDBConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"
   providerName="System.Data.SqlClient" />
  <add name="ConnectionString" connectionString="Expression: SampleData"
   providerName="System.Data.SqlClient" />
    <trace enabled="true" localOnly="false" />
    <compilation debug="true" />
    <roleManager enabled="true"/>
        <add namespace="System"/>
        <add namespace="System.Collections"/>
        <add namespace="System.Collections.Specialized"/>
        <add namespace="System.Configuration"/>
        <add namespace="System.Text"/>
        <add namespace="System.Text.RegularExpressions"/>
        <add namespace="System.Web"/>
        <add namespace="System.Web.Caching"/>
        <add namespace="System.Web.SessionState"/>
        <add namespace="System.Web.Security"/>
        <add namespace="System.Web.Profile"/>
        <add namespace="System.Web.UI"/>
        <add namespace="System.Web.UI.WebControls"/>
        <add namespace="System.Web.UI.WebControls.WebParts"/>
        <add namespace="System.Web.UI.HtmlControls"/>
       <authentication mode="Forms"/>
        <remove name="AspNetSqlMembershipProvider"/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" passwordStrengthRegularExpression=""/>
        <add name="FirstName"/>
        <add name="LastName"/>
        <add name="Address1"/>
        <add name="Address2"/>
        <add name="City"/>
        <add name="State"/>
        <add name="Zip"/>
        <add name="Phone"/>
        <add name="Email"/>
        <add name="ID"/>
    <customErrors mode="Off"/>
Question by:PrimeNY
    LVL 14

    Expert Comment

    Where you are trying to host your application ? If on any server than you have to change the connection string. You might also have to create the database on the server where you are copying the application.

    Author Comment

    Thanks for your comment.  Web site is being hosted by  Change connection string (where) in web.config to what?  What is involved to create database?
    LVL 14

    Accepted Solution

    That is all you have to retrive from godaddy.
    When you host web site they will have their help pages and knowledgebase where you can find out how to setup your database for your web site.

    Check this link.

    Hope it helps

    Expert Comment


    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
    Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now