473,698 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

opening & closing SQL connection

my application polls a database every X seconds.
Some times X = 0.5 seconds (500 milli seconds)

The way the code has been written, the SQL connection is opened & closed
during every poll.
Is this effecient?

Should i be leaving the connection opened & then polling the database every
500 milli seconds?
Or will the connection be simply picked up from the connection pool & hence
there isn't a drop in performance.

And also, there there's a message to be processed, then the processing of
this message would take 1-5 seconds, not longer.
What should i do?
Apr 17 '07 #1
1 3081
Best practices coding form dictates that you should open the connection
immediately prior to using it, and close it immediately following, which
allows it to return to the ADO.NET connection pool. You could experiment
with holding a connection open but you have to make sure you do not have
multiple threads doing this (such as a web page where hundreds of separate
requests would end up opening the same connection).
Regarding the timing issue, probably your processing should be done on a
background thread. Take a look at the BackgroundWorke r class for a simplified
mode for that.
Pete

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"LeAnne" wrote:
my application polls a database every X seconds.
Some times X = 0.5 seconds (500 milli seconds)

The way the code has been written, the SQL connection is opened & closed
during every poll.
Is this effecient?

Should i be leaving the connection opened & then polling the database every
500 milli seconds?
Or will the connection be simply picked up from the connection pool & hence
there isn't a drop in performance.

And also, there there's a message to be processed, then the processing of
this message would take 1-5 seconds, not longer.
What should i do?
Apr 17 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1342
by: Zlatko Matiæ | last post by:
Hello. I created a login form that creates connection string (DSN-less) and starts procedure that connects to PostgreSQL server.I didn't know how to connect to server without performing anything so I managed that connection is established by executing a query that returns current_user...I have two questions regarding that issue: 1. Is it possible to establish ODBC connection without performing query, so that such connection is used for...
0
5773
by: ʹÃûÑï | last post by:
ORA-03114: not connected to ORACLE && MS's Bug?? DataBase:Oracle 817 using OracleClient,net framework 1.1 I'm using ADO.Net in C# with Oracle 817. and following is my public data access class. using System.Data.OracleClient;
1
1794
by: hotice3100 | last post by:
I have created an interface for a SQL Reporting Service report. SQL Reporting Service makes a virutal directly in IIS called ReportServer. There are various buttons on the form I created and one is View. When the user clicks View, I fire a window.open, that has the URL string, to the ReportServer using URL access. This works find for virtually all reports. Unfortunately the SQL programmer has decided to use temp files for a few reports....
5
5222
by: Daves | last post by:
is it a good or bad practise to use the session_start & session_end for opening & closing the database connection? I'd thought that on powerful servers today the time the connection is kept locked should not matter as scripts (especially .Net!) are now run in milliseconds?
2
1630
by: Macca | last post by:
Hi, I am writing an app that will have a socket server to listen for and process data from 20+ clients. These clients will send data aproximately every 400-500ms. I was wondering if it is possible when i have established a connection with a client to keep that connection open rather than opening and closing every 400-500ms as i'd imagine there is overhead involved in this.
7
3250
by: Martien van Wanrooij | last post by:
I have been faced a couple of times with the situation that I wanted to write a script and was worried about a too frequent opening and closing mysql connections. To give some examples: 1)I am trying to develop a photoalbum (also posted a topic called "array / mysql question"). Of course I can use some wonderful open source albums but at the same time I want to get more familiar with all the ins and outs so my idea is a list of...
11
8602
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling mechanisms. I use a non-blocking approach for this, using the call to 'poll' to support the async mechanism - rather than the 'begin' and 'end' functions. I already found that connecting doesn't set the "isconnected" variable correctly...
4
2462
by: kessa | last post by:
Hi Guys, I've recently had a problem with my site displaying a "system resources exceeded" error message ... and whilst searching this site for a solution (which I think I've now found) I came across mention of closing database connections and so had a "best practice" question which I hoped someone might be able to help me with? I'm a .asp newbie and much of what I have learnt has been done by looking at various snippets of code on the web...
1
1399
by: No Name | last post by:
Hello, I have one BLL object X with method Y. Inside method Y (*) I call DAL object(s). Operation Y can include more then one DAL object (dalObj1.Write, dalObj2.Write) so I create some kind of "token" with sql connection reference and pass it to DAL object(s) involved in operation Y (**). At some point in time (ambient) transaction will finish (with success or
0
8675
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7729
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6521
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.