473,396 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C# Windows Service Thread Pool SQL Errors

I am a DBA and am working on a C# Windows Service to monitor a number of SQL Servers. I am collecting a number of items and storing them in a database for later reference. It is a pet project, and I could buy an off the shelf solution but I enjoy writing code. I have a problem in the implementation of my typed datasets and the way the threadpool I have for processing attempts to save data. If I start the service up, I can see it run and save data for a few cycles, but then at random points, it throws a SQL exception. Failed to Connect, Connection state connecting. Is this a problem with typed data sets, or have a built a non-safe set of code around connecting to SQL? The service instantiates a class that manages working with the tableadapters for me, and the class has to be instantiated for each call to save, so I wouldn't think it would be allowing a connection close by one thread while another thread is trying to use it, but I could be wrong. Does any of this make sense?

Jon
Mar 23 '07 #1
1 1808
I figured this out this morning. My problem was the way I made my tableadapter instance in code:

Problem Code:
private pm_Data dataconn = new pm_Data();
public void saveData(Object stateinfo)
{

PerfCounter pc = (PerfCounter)stateinfo;
dataconn.Insert(pc.ServerID, pc.CounterSetID, pc.UpdateTime, pc.CurrentValue);
}



Corrected Code:

public void saveData(Object stateinfo)
{
pm_Data dataconn = new pm_Data();

PerfCounter pc = (PerfCounter)stateinfo;
dataconn.Insert(pc.ServerID, pc.CounterSetID, pc.UpdateTime, pc.CurrentValue);
}

I missed this in changing this from single to multi-thread.

Jon
Mar 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Dan | last post by:
All, I have a windows service that creates a couple of worker threads to do some processing. The service works fine. However, the main service thread has a method for sending email notices that...
0
by: Andrew Dowding | last post by:
Hi Everybody, I have been looking at problems with my Windows Forms C# application and it's little Jet 4 (Access) database for the last few days. The Windows Forms app implements a facade and...
14
by: Brian Keating EI9FXB | last post by:
I wonder can anyone reccomment a solution to this problem. Let me explain, I've services running on my system, my application receives diagnostic messages from these services, what i want to do...
4
by: Bala | last post by:
Hi, After installing Win2K3 SP1, ASP.NET pages are not being rendered at all. I get a Access Denied error (BC31019: Unable to write to output file) OR a Page Cannot Be Displayed (PCBD) error...
1
by: RaggiHolm | last post by:
I am writing a service that I want to be able to display "debug" information on a desktop window. I have the following code that displays the form (when service is properly set up) and the service...
3
by: Chris | last post by:
Hi, I need to create a windows service that will poll a database every 10 sec and print processed orders to a printer. Where can I find info on this? Thanks
2
by: Peter Norregaard | last post by:
Our customers have different names SLA’s / Service Level Agreements but use the same webservice. How do I handle that some users can be allowed to wait when the load is high while others can’t?...
5
by: admin | last post by:
ok This is my main. Pretty much it goes through each category and starts up 4 worker threads that then ask for groups to gether from. My problem is that when the thread gets done it keeps the...
28
by: | last post by:
I have a multi threaded windows form application that runs great after calling Application.Run(). Application.Run is required for a COM component I a using in the app (required for message loop). ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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,...

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.