Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7626507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:20:04+00:00 2026-05-31T05:20:04+00:00

I have an ASP/C#(4.0) app that was been running on my machine for several

  • 0

I have an ASP/C#(4.0) app that was been running on my machine for several days. Suddently, in the middle of testing, I got this error. The app does seem to “wait” a short period before throwing the error. I was able to access the server via SQL-Management/Web/RDC/Ping just fine. I tried iisreset, recycling the app pool, and starting/stopping the app pool. Nothing got rid of the error until I rebooted. I’m assuming it has something to do with the connection pool and I figure I’m doing something wrong. This issue also affected the mini-iis that VS starts for debugging/etc.

I can’t currently get it to happen again, but I really hate problems that “fix themselves”. Since this can’t currently be tested, I’m just looking for direction and some ideas incase it comes up again.

Thanks 🙂

Exception information:
Exception type: SqlException
Exception message: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at MyApp.Default.BeginAsyncGetState(Object sender, EventArgs e, AsyncCallback cb, Object state) in C:…\Default.aspx.cs:line 65
at System.Web.UI.Page.PageAsyncInfo.CallHandlersPossiblyUnderLock(Boolean onPageThread)
at System.Web.UI.Page.PageAsyncInfo.CallHandlersCancellableCallback(Object state)
at System.Web.HttpContext.InvokeCancellableCallback(WaitCallback callback, Object state)
at System.Web.UI.Page.PageAsyncInfo.CallHandlers(Boolean onPageThread)

 public partial class Default : System.Web.UI.Page
    {

        SqlCommand _sqlCMD;
        SqlConnection _sqlConn = null;

         protected void Page_Load(object sender, EventArgs e)
        {
            String strStateCode = Request.QueryString["State"] ?? String.Empty;

            if (!Page.IsPostBack || !(Session["vchCurrentStateID"] ?? String.Empty).Equals(strStateCode))
            {
                AddOnPreRenderCompleteAsync(
                            new BeginEventHandler(BeginAsyncGetState),
                            new EndEventHandler(EndAsyncGetState)
                        );
            }
        }

         protected IAsyncResult BeginAsyncGetState(object sender, EventArgs e, AsyncCallback cb, object state)
        {
            String ConString = System.Configuration.ConfigurationManager.ConnectionStrings["ReportServer"].ConnectionString;
            _sqlConn = new SqlConnection(ConString);
            _sqlCMD = new SqlCommand();
            SqlDataReader myReader = null;

            _sqlCMD.Connection = _sqlConn;
            _sqlCMD.CommandType = CommandType.StoredProcedure;

            String strStateCode = Request.QueryString["State"] ?? String.Empty;

            IAsyncResult tmpResult = null;
            try
            {
                _sqlConn.Open();

                _sqlCMD.CommandText = "dbo.StateLevel_gState";
                _sqlCMD.Parameters.AddWithValue("@vchShortCode", strStateCode);

                tmpResult = _sqlCMD.BeginExecuteReader(cb, state);
            }
            catch (Exception ex)
            {
                if (_sqlConn != null)
                    _sqlConn.Close();
                if (_sqlCMD != null)
                    _sqlCMD.Dispose();
                if (myReader != null)
                    myReader.Dispose();

                throw;
            }
            return tmpResult;
        }

        void EndAsyncGetState(IAsyncResult ar)
        {
            try
            {
                using (SqlDataReader myReader = _sqlCMD.EndExecuteReader(ar))
                {
                    if (myReader.Read())
                    {
                        lblStateName.Text = myReader.GetString(1);
                        Session["iCurrentStateID"] = myReader.GetInt32(0);
                        Session["vchCurrentStateID"] = Request.QueryString["State"];
                        Session["vchReportLocation"] = myReader.GetString(3);
                    }
                    else
                    {
                        lblStateName.Text = "Invalid State";
                    }
                }
            }
            finally
            {
                if (_sqlConn != null)
                    _sqlConn.Close();

                if (_sqlCMD != null)
                {
                    _sqlCMD.Dispose();
                }
            }
        }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:20:05+00:00Added an answer on May 31, 2026 at 5:20 am

    Looks like its a named pipes issue and it could be a change to the database server that you don’t know about. Have a look at this: http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/

    Hope it helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL query in my ASP.net web app that looks like this:
I have an ASP.NET MVC app that I have been building, and I am
I have an issue that's been bugging me this morning. I'm building an ASP.NET
We have an ASP app that's sitting in an iframe on a page which
I have an ASP.NET app that sits on our intranet, using the WindowsIdentity to
I have an asp.net app that uses System.IO.Path.GetTempFileName() for temporary files. In the production
I have an ASP.NET Login App that creates a cookie called 'ASP_LOGIN77' and gives
So, I have an asp.net mvc app that is being worked on by multiple
We have an ASP.NET 2.0 WebForms app that uses MS Ajax 1.0. It's working
I have a asp.net web forms app that uses System.Web.Caching.Cache to cache xml data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.