Solved

Web configuration problem

Posted on 2006-11-03
6
183 Views
Last Modified: 2008-02-01
Hello Experts,
I am developing a web application with C# in VS2005. It runs fine from my development computer, but when I publish it out to the web server
I get the error below. The funny thing is, my connection strings point to a SQL Server 2000 box.  I've built several other web apps the same way and
they have worked fine.  Can you tell me what I'm missing?  I've included my web.config file at the bottom.
Thanks
Chad

Server Error in '/intranet' 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:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[SqlException (0x80131904): 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)]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734867
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
   System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failoverDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean aliasLookup) +820
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +130
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
   System.Data.SqlClient.SqlConnection.Open() +111
   System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +84
   System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +197
   System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider.GetConnectionHolder() +16
   System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider.LoadPersonalizationBlobs(WebPartManager webPartManager, String path, String userName, Byte[]& sharedDataBlob, Byte[]& userDataBlob) +195
   System.Web.UI.WebControls.WebParts.PersonalizationProvider.LoadPersonalizationState(WebPartManager webPartManager, Boolean ignoreCurrentUser) +95
   System.Web.UI.WebControls.WebParts.WebPartPersonalization.Load() +105
   System.Web.UI.WebControls.WebParts.WebPartManager.OnInit(EventArgs e) +497
   System.Web.UI.Control.InitRecursive(Control namingContainer) +321
   System.Web.UI.Control.InitRecursive(Control namingContainer) +198
   System.Web.UI.Control.InitRecursive(Control namingContainer) +198
   System.Web.UI.Control.InitRecursive(Control namingContainer) +198
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210


***web.config****
<?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
      <appSettings>
            <add key="ConnectionString" value="data source=server;uid=user;pwd=pwd;initial catalog=Portal"/>
            <add key="ConnectionStringTips" value="integrated security=SSPI;data source=server;persist security info=True;initial catalog=Tips"/>
      </appSettings>
      <connectionStrings/>
      <system.web>
            <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
            <compilation debug="true">
                  <assemblies>
                        <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>
            <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
            <authentication mode="Windows"/>
            <authorization>
                  <deny users="?"/>
            </authorization>
            <identity impersonate="true"/>
            <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.
   -->
        <customErrors mode="Off" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
     
      </system.web>
</configuration>
0
Comment
Question by:ChadMarsh
  • 3
  • 2
6 Comments
 
LVL 28

Accepted Solution

by:
strickdd earned 500 total points
ID: 17868451
Make sure that the IIS anonymous user is setup on the webserver. When you develop locally you are logging into SQL via your windows login user. Once you  verify the IIS user is set up, make sure your trusted user is on the DB you need with the proper permissions. Lastly, it could be an intermittent connection problem and could start working all of a sudden.
0
 
LVL 2

Author Comment

by:ChadMarsh
ID: 17868498
Thanks for the response.
I'm not sure I follow you.  I have my IIS setup to not allow anonymous and to use integrated security it's also set up to delegate.
0
 
LVL 28

Expert Comment

by:strickdd
ID: 17868543
If you have Integrated Windows Authentication turned on, you will have to make sure that the user loging in to the site has access to the DB. If this can't be done, then you will want to not use trusted connections. This whole problem is occurring, i believe, because the user trying to access SQL does not have access rights.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Author Comment

by:ChadMarsh
ID: 17868917
The user is me and I am the db_owner. I took all of my web controls off of the Default.aspx page so there shouldn't be any code running that would access the database and I still get the error. Does ASP.NET access the mdf file that is automatically creates? I'm starting to wonder if it's that because sometimes with I go to publish, the build fails saying that the ASPNETDB.MDF is tied up
0
 
LVL 11

Expert Comment

by:lijunguo
ID: 17870996
<<The funny thing is, my connection strings point to a SQL Server 2000 box.
But from exception details, you connect to a SQL 2005 SERVER. The connection string  for 2000 and 2005 is different.

See this link, get all connection string you want
http://www.connectionstrings.com/
0
 
LVL 2

Author Comment

by:ChadMarsh
ID: 17880770
I think I've found out what's causing my problem. Maybe this will help. I am using webparts in this application, which I haven't used in the others that work.
It appears that the database that .NET creates (aspnetdb.mdf) needs to be accessed it get information about these webparts. That's where my SQL2005 error is coming from. So it's not my SQL2000 connection string that's causing the problem.  I need to figure out why it will not access that local SQL express database.
Any Ideas?
Thanks for your posts and I appreciate your help
Chad
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

11 Experts available now in Live!

Get 1:1 Help Now