[SqlException (0x80131904): An error has occurred while establishing a connection to the server...

Discussion in 'Databases' started by wisemx, Jan 4, 2008.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi Folks,
    I am a newbie and need help. Here is my scenario.

    I have just uploaded my website to the server. If I amNOT logged in , then I am able to visits all of my pages and view data (derived from SQL 2005 Database, very sweet). The issue arrives when I am successfully LOGGED IN. In case I am logged in, I am not able to see all of the pages which have this statement in the page load "Users.IsInRole("admin"). I get the SQL exception below. Could someone please help? Thanks in advance.

    Stack Trace:






    Code:
    [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) +800131
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186
       System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) +737554
       System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +114
       System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +421
       System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +181
       System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +173
       System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +133
       System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +30
       System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
       System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
       System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +494
       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.Security.SqlRoleProvider.GetRolesForUser(String username) +771
       System.Web.Security.RolePrincipal.IsInRole(String role) +272
       NewsMain.Page_Load(Object sender, EventArgs e) in e:\web\daymadiorg0\htdocs\NewsMain.aspx.cs:42
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
    
     
  2. Can you post your SQL Server conn section from the web.config?
    (Edit out any private areas with *****,i.e. Password.)
     
  3. Here is the connectionString. Again, if I am not logged in, I am able to traverse through the sites, and everything works fine. The exception occurs


    when I am successfully logged in, and try to view the pages which has this "Users.IsInRole("admin") in it (I debugged it and it failed right there).


    For pages that do not have that "Users.IsInRole("admin"), I am able to view them fine and data derived from DB also shows up fine.


    <connectionStrings>
    <add name="DatabaseConnectionString" connectionString="Data Source=tcp:sql2k504.discountasp.net; Initial Catalog=SQL2005_445593_01;User ID=************;Password=**************;"/>
    </connectionStrings>
    <system.web>



    <membership defaultProvider = "SqlProvider" userIsOnlineTimeWindow = "20">
    <providers>
    <remove name = "AspNetSqlProvider" />
    <add name = "SqlProvider"
    type = "System.Web.Security.SqlMembershipProvider"
    connectionStringName = "DatabaseConnectionString"
    enablePasswordRetrieval = "false"
    enablePasswordReset = "true"
    requiresQuestionAndAnswer = "true"
    passwordFormat = "Hashed"
    applicationName = "/" />
    </providers>
    </membership>
     
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