Connection string in WEB.CONFIG for SQL Server 2005

Last post 08-05-2008 11:27 PM by chetan.sarode. 18 replies.

Sort Posts:

  • Connection string in WEB.CONFIG for SQL Server 2005

    07-13-2006, 6:33 PM
    • Loading...
    • Tryst
    • Joined on 08-15-2004, 10:31 AM
    • Wales
    • Posts 286
    Hi all,

    I now know that the .mdf file (I don't have a .ldf file for some reason, does this not come with the latest download of the TimeTracker starter-kit?) must stay in the app_data directory. But, I have SQL Server 2005 and so the connection strings in the default WEB.CONFIG file are for SQL Express

    <connectionStrings>
            <add name="aspnet_staterKits_TimeTracker" connectionString="Data Source=.\SQLExpress;Integrated Security=True;AttachDBFilename=|DataDirectory|TimeTracker.mdf;User Instance=true" />
            <remove name="LocalSqlServer"/>
            <add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;AttachDBFilename=|DataDirectory|TimeTracker.mdf;User Instance=true" />
        </connectionStrings>


    How do I change these to work with SQL Server 2005?

    Hope you can help.

    Thanks

    Tryst
  • Re: Connection string in WEB.CONFIG for SQL Server 2005

    07-18-2006, 10:14 AM
    • Loading...
    • Evolver
    • Joined on 07-18-2006, 2:10 PM
    • Posts 2

    This is a correct connection string if the SQL Database is on the server, If the SQL Database is on another server you can point it out with server=COMPUTERNAME\SQLExpress

    If you have another instance name of the database you can change it to..

    <

    add name="aspnet_staterKits_TimeTracker" connectionString="server=.\SQLExpress;uid=timetraxuser;pwd=timetraxpassword;database=timetrax"/>

    <

    remove name="LocalSqlServer"/>

    <

    add name="LocalSqlServer" connectionString="server=.\SQLExpress;uid=timetraxuser;pwd=timetraxpassword;database=timetrax"/>

    /Jonas

  • Re: Connection string in WEB.CONFIG for SQL Server 2005

    10-05-2006, 8:01 AM
    • Loading...
    • kimmeyer
    • Joined on 05-25-2006, 10:45 AM
    • Posts 13

    Hi,

    I have a similar issue and was wondering if you resolved what needed changing in the config file when moving it Sql Server 2005, I get the following error when attempting to login. This instance is setup to allow remote connections and is happily running other applications so I think this generic error is not really telling the story. I suspect the issue is with the default Express version of the Web.config and I am not experienced enough at the  moment to determine what, so my getting started experience has come to an abrupt stop.

     

    Server Error in '/' Application.

    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)

    Thanks

    Kim

  • Re: Connection string in WEB.CONFIG for SQL Server 2005

    04-25-2007, 12:13 AM

    Open "SQL Server Surface Area Configuration"

    then opne the "Surface Area Configuartion for Services and Connections "

    Under the Remote connection u have to enable the "Using both TCP/IP and Named  Pipes "

    then It will work..

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
  • Re: Connection string in WEB.CONFIG for SQL Server 2005

    11-29-2007, 7:58 PM
    • Loading...
    • edba1970
    • Joined on 08-30-2007, 3:02 AM
    • Posts 20

    I have a similar problem. I have everything working locally and have copied a published version to a hosting server from GoDaddy. I get an error similar to the one above

    ... (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

     

    I was looking on line and tried some suggestions but none worked. Here's what I have under my web.config file:

     
        <connectionStrings>
            <add name="vsItemsConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\vsItems.mdf;Integrated Security=True;User Instance=True"
             providerName="System.Data.SqlClient" />
        </connectionStrings>
    
    
     

    Then I have added the following lines under <system.web> which I copied from the website as the suggestion:

     

           <membership>
    
          <providers>
             <remove name="AspNetSqlMembershipProvider" />
             <add name="AspNetSqlMembershipProvider"
               type="System.Web.Security.SqlMembershipProvider,
               System.Web, Version=2.0.0.0, Culture=neutral,                                
               PublicKeyToken=b03f5f7f11d50a3a"
               connectionStringName="vsItemsConnectionString"
               enablePasswordRetrieval="false"
               enablePasswordReset="true"
               requiresQuestionAndAnswer="true"
               applicationName="/"
               requiresUniqueEmail="false"
               passwordFormat="Hashed"
               maxInvalidPasswordAttempts="5"
               minRequiredPasswordLength="7"
               minRequiredNonalphanumericCharacters="1"
               passwordAttemptWindow="10"
               passwordStrengthRegularExpression="" />
           </providers>
    
       </membership>
    
       <profile>
           <providers>
              <remove name="AspNetSqlProfileProvider" />
              <add name="AspNetSqlProfileProvider"
                 connectionStringName="vsItemsConnectionString"                           
                 applicationName="/"
                 type="System.Web.Profile.SqlProfileProvider,
                 System.Web, Version=2.0.0.0, Culture=neutral,                   
                 PublicKeyToken=b03f5f7f11d50a3a" />
            </providers>   
       </profile>
    
       <roleManager>
            <providers>
              <remove name="AspNetSqlRoleProvider" />
              <add name="AspNetSqlRoleProvider"
                 connectionStringName="vsItemsConnectionString"
                 applicationName="/"
                 type="System.Web.Security.SqlRoleProvider,
                 System.Web, Version=2.0.0.0, Culture=neutral,                               
                 PublicKeyToken=b03f5f7f11d50a3a" />
            </providers>
       </roleManager>
    
     

    I still get the same error. By the way I am using SQL Express which is built-in to .NET

    Any idea how to go about fixing this? Any help would be appreciated.

    Thank you.
     

  • Re: Connection string in WEB.CONFIG for SQL Server 2005

    11-29-2007, 10:34 PM

    Try to set Data Source= "serverName" in you connectionString

    Data Source=.\SQLEXPRESS will work only on local m/c, It will not work if you host your site

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
  • Re: Connection string in WEB.CONFIG for SQL Server 2005

    02-11-2008, 5:49 AM
    Tryst:
    How do I change these to work with SQL Server 2005?

    Hi,

    When using this starter kit with Sql Server 2005, this worked for me.

    BTW, if you get the error about not finding the stored proc / something to do with creating the schema, follow the advice in some of the posts about the aspnet_regsql.exe - it worked for me!!

    Hope this helps.

    Cheers

    Please click "Mark As Answer" if indeed this is the case.
  • Re: Connection string in WEB.CONFIG for SQL Server 2005

    02-11-2008, 10:27 PM

    Set Try to set Data Source = "Server name" in connection string

    Open "SQL Server Surface Area Configuration"

    then opne the "Surface Area Configuartion for Services and Connections "

    Under the Remote connection u have to enable the "Using both TCP/IP and Named  Pipes "

    then It will work..

    Try to set Data Source= "serverName" in you connectionString

    Data Source=.\SQLEXPRESS will work only on local m/c, It will not work if you host your site

    Check in web.config for connectionString, configure it according to your server name, password etc.

    In Time Tracking System, it uses inbuild Membership classes for user creation, updation etc..

    You have to register your DB with ASP.NET Membership classes by executing the command line utility in VS prompt

    aspnet_regsql, it will open one window, where you  have to configure DB.

    Hope it will help you, let me know.

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
  • Re: Connection string in WEB.CONFIG for SQL Server 2005

    02-12-2008, 10:26 PM

    Have you tried my solution

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
  • Re: Connection string in WEB.CONFIG for SQL Server 2005

    02-18-2008, 10:22 PM

    What is the status of your post

    Have you solved your problem

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
  • Re: Connection string in WEB.CONFIG for SQL Server 2005

    02-26-2008, 6:10 AM
    • Loading...
    • deektweek
    • Joined on 02-22-2008, 9:46 AM
    • Posts 14

    i am the same connection errors but i do not have SQLEXPRESS in my config file. I connect to two sql servers without issues from my local machine (running developer edition).

    I DO notice that the asp.net properties on IIS6 holds data source=./SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true

     Could this be the issue and why is it there?
     

  • Re: Connection string in WEB.CONFIG for SQL Server 2005

    02-26-2008, 10:37 PM

    Change in connectionString User Instance = false

    <connectionStrings>
      <add name="aspnet_staterKits_TimeTracker" connectionString="Data Source=RELSEC_FE\SQLServer2005;Integrated Security=True;AttachDBFilename=|DataDirectory|TimeTracker.mdf;User Instance=false"/>
      <remove name="LocalSqlServer"/>
      <add name="LocalSqlServer" connectionString="Data Source=RELSEC_FE\SQLServer2005;Integrated Security=True;AttachDBFilename=|DataDirectory|TimeTracker.mdf;User Instance=false"/>
     </connectionStrings>

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
  • Re: Connection string in WEB.CONFIG for SQL Server 2005

    04-28-2008, 8:24 AM
    • Loading...
    • Geek-O
    • Joined on 04-25-2008, 6:36 AM
    • Posts 29

     This is the error i am getting. This is the first time i have published an app to the web using ASP.net. I used the copy website feaure in VS2008, this is all i have done so far and i receive this error.

    Server Error in '/' Application.

    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:

    Line 11:         if (Roles.Enabled)
    Line 12: {
    Line 13: if (!Roles.RoleExists("ProjectAdministrator"))
    Line 14: {
    Line 15: Roles.CreateRole("ProjectAdministrator");

    Source File: d:\hshome\voobiz\corp.voobon.net\Global.asax    Line: 13
     

     

    This is my config file:

    <?xml version="1.0"?>
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
      <connectionStrings>
        <add name="aspnet_staterKits_TimeTracker" connectionString="Data Source=.\SQLExpress;Integrated Security=True;AttachDBFilename=|DataDirectory|TimeTracker.mdf;User Instance=true" />
        <remove name="LocalSqlServer"/>
        <add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;AttachDBFilename=|DataDirectory|TimeTracker.mdf;User Instance=true" />
      </connectionStrings>
      <system.web>
        <siteMap defaultProvider="AspNetXmlSiteMapProvider" enabled="true">
          <providers>
            <clear />
            <add name="AspNetXmlSiteMapProvider"
                        type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                        siteMapFile="web.sitemap"
                        securityTrimmingEnabled="true"  />
          </providers>
        </siteMap>
        <authentication mode="Forms">
          <forms loginUrl="~/TimeTracker/login.aspx"/>
        </authentication>
        <compilation debug="true" />
        <customErrors mode="Off"/>
        <machineKey decryptionKey="AutoGenerate,IsolateApps"/>
        <roleManager enabled="true" />
      </system.web>
    </configuration>

  • Re: Connection string in WEB.CONFIG for SQL Server 2005

    06-18-2008, 11:27 PM

    You have to register your DB with ASP.NET Membership classes by executing the command line utility in VS prompt

    aspnet_regsql, it will open one window, where you  have to configure DB.

    Add the following lines under <system.web>

           <membership>
    
          <providers>
             <remove name="AspNetSqlMembershipProvider" />
             <add name="AspNetSqlMembershipProvider"
               type="System.Web.Security.SqlMembershipProvider,
               System.Web, Version=2.0.0.0, Culture=neutral,                                
               PublicKeyToken=b03f5f7f11d50a3a"
               connectionStringName="vsItemsConnectionString"
               enablePasswordRetrieval="false"
               enablePasswordReset="true"
               requiresQuestionAndAnswer="true"
               applicationName="/"
               requiresUniqueEmail="false"
               passwordFormat="Hashed"
               maxInvalidPasswordAttempts="5"
               minRequiredPasswordLength="7"
               minRequiredNonalphanumericCharacters="1"
               passwordAttemptWindow="10"
               passwordStrengthRegularExpression="" />
           </providers>
    
       </membership>
    
       <profile>
           <providers>
              <remove name="AspNetSqlProfileProvider&