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

  • Home
  • SEARCH
  • 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 139589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:27:44+00:00 2026-05-11T07:27:44+00:00

I have a rather simple web-service which exposes data from sql server. It will

  • 0

I have a rather simple web-service which exposes data from sql server. It will be used to synchronize data between 2 different databases (SQL Server and Lotus Notes). We’re in the stage of testing the web-service and poll it with 20 req./min., the first 2 minutes it goes OK, but after the second, we’re getting an exception, obviously the connection (to the database) can’t be opened(timeout).

Do you have any tips/recommendations on what to do or where to look at? The web-service has been programmed using C#/.NET, the connection to the db is opened during construction of (web-service) object and closed when the object is disposed.

I’ve considered using global.asax to ‘share’ the connection but after some googling I found out most people find that a bad idea and I’m looking for a different solution.

ps. the service is pooled in a synchronous way, no 2 requests exist at the same time

-edit- (after first 2 anwsers about pooling) This is current code:

public class DataService : System.Web.Services.WebService {     private SqlConnection conn = new SqlConnection('Data Source=ip;database=database;uid=user;pwd=secret;');     public DataService ()      {             try             {                 conn.Open();              }             catch (Exception dbconn)             {                 throw new SoapException('Couldn't open connection to database:' + dbconn.Message + ' More info at: ' + dbconn.HelpLink, errorCode);             }             //Uncomment the following line if using designed components              //InitializeComponent();      }     ~DataService()     {          conn.Close();     }     [WebMethod(Description='Gets all Person changes(from last week)')]     public Person[] GetPerson()     {              Person[] Personen = null;             SqlCommand sqlcmd = conn.CreateCommand();              sqlcmd.CommandText = 'SELECT * FROM Person';             SqlDataReader Rows = sqlcmd.ExecuteReader();             while (Rows.Read())             {                     //doSomething             }              Rows.Close();             return Personen;     } 

}

  • 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. 2026-05-11T07:27:44+00:00Added an answer on May 11, 2026 at 7:27 am

    Sounds like you’ve exhausted the connection pool — best option is to wrap you SQL calls with using blocks, loosely thus:

    using( SqlConnection con = new SqlConnection( 'MyConnectionString' ) ) {     con.Open();      using( SqlCommand cmd = new SqlCommand( 'MyStoredProcedure', con ) )     {         // Do stuff with the Command     } } 

    This will allow you to serve concurrently the same number of requests as the size of your connection pool.

    So, the code after your edit becomes:

    public class DataService : System.Web.Services.WebService {     [WebMethod(Description='Gets all Person changes(from last week)')]     public Person[] GetPerson()     {          Person[] Personen = null;          using( SqlConnection conn = new SqlConnection('Data Source=ip;database=database;uid=user;pwd=secret;') )         {             using( SqlCommand sqlcmd = conn.CreateCommand() )             {                 sqlcmd.CommandText = 'SELECT * FROM Person';                 SqlDataReader Rows = sqlcmd.ExecuteReader( CommandBehavior.CloseConnection ); // This will close the DB connection ASAP                 while (Rows.Read())                 {                     //doSomething                 }                  Rows.Close();             }         }          return Personen;     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 110k
  • Answers 110k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use a ValueConverter that inverts a bool property… May 11, 2026 at 9:32 pm
  • Editorial Team
    Editorial Team added an answer Yes, e.printStackTrace(); writes to stderr (standard error stream). Since cfexecute… May 11, 2026 at 9:31 pm
  • Editorial Team
    Editorial Team added an answer To get a handle to the drop down list inside… May 11, 2026 at 9:31 pm

Related Questions

(Edited to add an example and hopefully make it a bit clearer) I'm mainly
Following on from my recent question on Large, Complex Objects as a Web Service
I have a list of objects and I would like to access the objects
I need to process large image files into smaller image files. I would like

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.