Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ado not releasing connections

Status
Not open for further replies.

yeller2

Programmer
Feb 8, 2007
69
0
0
US
Howdy,

When doing a lot of database reads and writes to different machines (taking data from one and putting onto another through intermediary), I eventually get an error where the port I'm connecting to is above 5000. When I do a netstat /na I can see that many connections are in TIME_WAIT state. I've tried manually closing these and there is not difference. Any ideas? The connection objects are going out of scope? Should I manually garbage collect?

thanks
 
By the way, the executing environment is .net 2.0 on a win xp machine.
 
Try following two things:

1) Put everything in try{} and catch{} block, especially whereever the connection is opened, put it into try and catch block and in "finally", close the connection.

2) Use your connection like this:
using (SqlConnection Conn = new SqlConnection())
{
.... // use above connection
}

Ch Saj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top