473,399 Members | 3,038 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,399 software developers and data experts.

Problem with WebServices Data connections

My apologies if this is not the most appropriate group for this, and
please feel free to redirect me.

I have written a webservice for a client. It's relatively straight
forward, with a published method taking an array of items, and writing
each item to a database. The database is an SQL Server 2005. The
program is implemented in C# using VS 2005.

The method structure is also pretty straightforward (abbreviated to
just the relevant parts):

public errorObject[] ListMethod(objectList[] newObjects)
{
SqlConnection conn = new
SqlConnection(WebConfigurationManager.ConnectionSt rings["ConnectionStringName"].ConnectionString);

SqlCommand cmd = new SqlCommand("INSERT INTO table
(dataelemnts) VALUES (@custPhoneNumb, @timeStart, @callRecordID)");
cmd.Connection = conn;
try
{
conn.Open();
}
catch (SqlException ex)
{
// log exception
}
for (int ix = 0; ix < newObjects.GetLength(0); ix++)
{
// process objects
cmd.Parameters.Clear();
cmd.Parameters.Add("@param1", SqlDbType.Char,
dataElement1.Length).Value = dataElement1
cmd.Parameters.Add("@timeStart",
SqlDbType.DateTime).Value = DateTime.Now;
cmd.Parameters.Add("@callRecordID",
SqlDbType.VarChar).Value = customer.callRecordID;
try
{
err = false;
if (cmd.ExecuteNonQuery() != 1)
{
err = true;
}
}
catch (SqlException ex)
{
// log exception
}
}
try
{
conn.Close();
}
catch (SqlException ex)
{
// log exception
}
}

There are no returns or other branches that would short-circuit the
execution path without going through the try conn.Close().

After a couple months in operation, the client has observed a huge
number of open database processes (using the Activity Monitor) with
the user id that only this webservice uses. Each process is in a
"Sleeping" status, and shows a "Command" Column of "AWAITING COMMAND"
and an application of ".Net SqlClient DataProvider". This seems to be
(eventually) running into an open connection or some other resource
limitation of the server and is impacting performance.

Can anyone give me a clue as to what is happening and where these open
processes are coming from? When they first contacted me, my first
thought was I just needed to make sure I was putting in appropriate
conn.Close() calls, but on reviewing the code (it's been 3 months
since I looked at it), I see they are already there. My understanding
is that once you call conn.Close, that connection is done until you
call conn.Open() to start a new one. Is there some garbage that it
leaves behind that somehow needs to be cleaned up? Also, to insure
thread safety, I allocated the conn object within the Method call.
which means that it shoujld be garbage collected when it goes out of
scope at the end of the method, right? I've thought of adding a
conn.Dispose() at the end, but I'm not convinced that would have any
affect other than perhaps a slight performance hit. I've also thought
of making the conn object a static member object so there's only one
of them, but I'm concerned that multiple simultaneous calls to the
method might end up walking all over each other's DB interactions.

There is probably a group more centered on Database issues that this
post would be more appropriate for, but I couldn't find it. So if
anyone has any help or suggestions, I would be most appreciative.
Sep 13 '08 #1
1 1021

"daveh551" <ge****@gmail.comwrote in message
news:31**********************************@c58g2000 hsc.googlegroups.com...
There is probably a group more centered on Database issues that this
post would be more appropriate for, but I couldn't find it. So if
anyone has any help or suggestions, I would be most appreciative.
It seems to me that your code would test for the connection being open and
close at the end of your code. Maybe, your code is blowing up on a non
handled exception, because you're only looking at SQL exceptions, and it's
blowing past the close() and the connection is never closed, left hanging.

You should test for the connection being open before the code is left and
close it if it's still open.

Sep 16 '08 #2

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

Similar topics

2
by: Programatix | last post by:
Hi, I'm working on a project which includes WebServices and Windows Form application. The Windows Form application will call the WebServices to retrieve data from database. The data will be...
0
by: Refky Wahib | last post by:
Hi I need Technical Support I finished a Great project using .Net and SQL Server and .Net Mobile Control My Business case is to implement this Program to accept about 1 Million concurrent...
1
by: Refky Wahib | last post by:
Hi Actually I need Technical Support I finished a Great project using .Net and SQL Server and .Net Mobile Control My Business case is to implement this Program to accept about 1 Million...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
0
by: Pasho | last post by:
hi I have been facing problem using C# webservices (secured using SSL). In my webservice(secured with SSL) It works fine if I try to access data from database through dataset. If I try to...
3
by: Mike | last post by:
I have created a web service for a client to consume. The element I am having trouble with is, as described in their WSDL: <xsd:element minOccurs="0" ref="LocalData" maxOccurs="1" /> ...
1
by: J. Askey | last post by:
I am implementing a web service and thought it may be a good idea to return a more complex class (which I have called 'ServiceResponse') in order to wrap the original return value along with two...
5
by: Usman Jamil | last post by:
Hi I've a class that creates a connection to a database, gets and loop on a dataset given a query and then close the connection. When I use netstat viewer to see if there is any connection open...
5
by: =?Utf-8?B?cnZhbmdlbGRyb3A=?= | last post by:
Hello, I have a problem with our OnlineBackupService.exe. This is a Windows Service which is built in .Net 1.1 and basically grabs files from the file system and will try to upload them using...
1
by: sherifbk | last post by:
Problem description ============== - I have 4 clients and 1 server (SQL server) - 3 clients are Monitoring console 1 client is operation console - Monitoring console collects some data from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
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...

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.