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 7716237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:35:10+00:00 2026-06-01T02:35:10+00:00

I keep getting this error randomly: System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request.

  • 0

I keep getting this error randomly:

System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. —> System.InvalidOperationException: The connection was not closed. The connection’s current state is connecting.

The code it’s complaning about is below:

        DataSet ds = new DataSet(); 
        cn = new SqlConnection(GetDBConnectionString()); 

        using (cn) 
        { 
            try 
            { 
                SqlCommand cmd = new SqlCommand("uspGetNavigationItems", cn); 
                cmd.CommandType = CommandType.StoredProcedure; 
                cn.Open(); 
                SqlDataAdapter adp = new SqlDataAdapter(cmd); 
                adp.Fill(ds, "NavItems"); 
            } 
            catch (Exception ex) 
            { 
                ds = null; 
                throw ex; 
            } 
            finally 
            { 
                if (cn.State != ConnectionState.Closed) 
                { 
                    cn.Close(); 
                } 
            } 
        } 

        if (ds.Tables.Count > 0) 
        { 
            if (ds.Tables[0].Rows.Count > 0) 
            { 
                return ds.Tables[0]; 
            } 
            else 
            { 
                return null; 
            } 
        } 
        else 
        { 
            return null; 
        }

I don’t understand where the problem is, why it’s saying the connection is connecting, when I have a finally to clean it up. Is it because i’m using Finally to close and the using statement, which is supposed to close it as well? Again this happens randomly not always, that’s why i’m not sure what’s going on.

Thank you.

  • 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-06-01T02:35:11+00:00Added an answer on June 1, 2026 at 2:35 am

    You don’t need to close the connection in finally if you’re using the using-statement since it will close it from dispose implicitely.

    Rule of thumb: use the using-statement for every class implementing IDisposable(like Connections,DataAdapter,Commands). On the other hand, a DataSet or a DataTable does not implement it and does not need to be disposed manually or via using.

    But change:

    cn = new SqlConnection(GetDBConnectionString()); 
    using (cn) 
    {
        //code
    }
    

    to:

    using (var cn = new SqlConnection(GetDBConnectionString())) 
    {
        //code
    }
    

    This will be translated to:

    SqlConnection cn = new SqlConnection(GetDBConnectionString());
    try
    {
        //code
    }
    finally
    {
        if (cn != null)
           ((IDisposable)cn).Dispose();
    }
    

    Sidenote: throw instead of throw ex would keep the stacktrace. With throw ex you’re hiding the original source of the exception.

    https://stackoverflow.com/a/22628/284240

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

Sidebar

Related Questions

We keep getting this error randomly in our web application. System.Data.SqlClient.SqlException: A network-related or
I keep getting this error System.Web.HttpException was unhandled by user code Message=Validation of viewstate
Okay this is werid, i keep getting the error, randomly. ValueError: matrix must be
I keep randomly getting this error within my Drupal site. Only way to resolve
I keep getting this error when making the program as given below: using System;
I keep getting this error when I deploy my application in the server machine
I keep getting this error: System.Runtime.InteropServices.COMException was thrown on C:\Users\---\documents\visual studio 2010\Projects\TBrowser\TBrowser\TBrowserWindow.xaml: Error HRESULT
I randomly keep getting this error when switching from Debug to Release when building
i keep getting this error: Exception Details: System.NotSupportedException: Cannot serialize member HannaPrintsDataAccess.Customer.CustomerAddresses of type
Keep getting this error after inserting a subdatasheet into a query and trying to

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.