Search
ODBC Connection Hangs on Close
Started by Liago at 09-08-2005 6:19 AM. Topic has 7 replies.

Print Search Next Thread »
  09-08-2005, 6:19 AM
Liago is not online. Last active: 6/15/2006 10:30:17 PM Liago

Top 10 Posts
Joined on 04-22-2005
Posts 25
ODBC Connection Hangs on Close
Reply Quote

We have legacy databases being accessed from ASP.NET.  Using the Microsoft.Data.Odbc reference we are able to make a connection and read the data.  However, if we try to close the connection the page hangs and will continue processing indefinitely.  If we skip the close step the page processes normally, but the connection remains active on our server.  The connections will all pile up until our license count is exceeded  in DataAccess, the software that allows us to connect to mainframe databases.

We are able to open and close connections normally to SQL Server databases.  Has anyone ever had a  similar problem?  What was your solution?


   Report 
  09-08-2005, 6:40 AM
jbrunken is not online. Last active: 5/5/2008 6:35:16 AM jbrunken

Top 10 Posts
Joined on 04-05-2005
Cedar Rapids
Posts 66
Re: ODBC Connection Hangs on Close
Reply Quote

Strange...

How are you accessing the data?  If you're using something like a "DataReader", are you closing it before you try and close the connection?

Also, I wonder if connection pooling could be playing a role in this problem...

-JB


   Report 
  09-08-2005, 7:04 AM
Liago is not online. Last active: 6/15/2006 10:30:17 PM Liago

Top 10 Posts
Joined on 04-22-2005
Posts 25
Re: ODBC Connection Hangs on Close
Reply Quote

We are using a DataReader.  In the case of using ODBC, it's a specific reader:  Microsoft.Data.Odbc.OdbcDataReader.

We are closing the DataReader first.

I don't know anything about connection pooling, but we'll look into it.


   Report 
  09-08-2005, 7:27 AM
jbrunken is not online. Last active: 5/5/2008 6:35:16 AM jbrunken

Top 10 Posts
Joined on 04-05-2005
Cedar Rapids
Posts 66
Re: ODBC Connection Hangs on Close
Reply Quote

Are you sure you have the latest version of ODBC for .NET?   The most recent version that I saw was 1.0.4030.0

Also, make sure you have the latest MDAC installed.

-JB


   Report 
  09-08-2005, 8:48 AM
Liago is not online. Last active: 6/15/2006 10:30:17 PM Liago

Top 10 Posts
Joined on 04-22-2005
Posts 25
Re: ODBC Connection Hangs on Close
Reply Quote

We are using the latest version of ODBC for .NET.  Downloaded from here: http://www.microsoft.com/downloads/details.aspx?FamilyID=6ccd8427-1017-4f33-a062-d165078e32b1&displaylang=en

We'll have to check into the MDAC version.

Thanks


   Report 
  09-08-2005, 9:37 AM
jbrunken is not online. Last active: 5/5/2008 6:35:16 AM jbrunken

Top 10 Posts
Joined on 04-05-2005
Cedar Rapids
Posts 66
Re: ODBC Connection Hangs on Close
Reply Quote

If you're using XP with SP2, then you've probably got the latest MDAC...

I would definitely look into connection pooling.   It's turned ON by default, so you might try turning it off.  You have to use the ODBC administration tool as ODBC does not use the "POOLING=" value from the command string.

-JB


   Report 
  09-09-2005, 11:59 AM
Liago is not online. Last active: 6/15/2006 10:30:17 PM Liago

Top 10 Posts
Joined on 04-22-2005
Posts 25
Re: ODBC Connection Hangs on Close
Reply Quote

I'm learning about pooling.  I wanted to run something by this forum and see if I'm thinking straight.

With pooling, a connection will be reused if it is available.  If not, another connection will be created until the max pool size is reached.

In our case, since we are having trouble closing our ODBC connection, all pooled connections are always busy so new connections are always needed and added to the pool.  This continues until our license count is exceeded in our mainframe connection software (reached after only 8 connections on development, well below the max pool size).

If I'm right, this means the problem still remains that we need to be able to close the ODBC connections effectively.  Perhaps it would also be a good idea to set a max pool size so that we don't exceed our license count in the event of heavy traffic.

What do you think?


   Report 
  09-22-2005, 10:22 AM
NickStineman is not online. Last active: 9/22/2005 5:12:27 PM NickStineman

Top 10 Posts
Joined on 07-19-2005
Posts 8
Re: ODBC Connection Hangs on Close
Reply Quote

You're exactly right about closing the connection.  That is a major issue as the connection will never be destroyed in the pool.  As far as I know min & max pool size are attributes exclusive to the SqlClient.

What ODBC driver are you using?  I'd research the inability to close the connection before diving too deep into the pooling side of things.  Pooling on or off not being able to close/dispose the connection is troubling.

That being said, below are some notes on my experiences with pooling.

I've read somewhere that it is possible to enable & disable connection pooling via the ODBC administrator.  I've got version 3.5 of the administrator & all I can do is enable or disable the performance monitor & set the retry wait.  I would recommend turning on the performance monitor & reviewing the entries made.  If you search MSDN you can find articles about reading the performance monitor for the connection pooling entries.

One way to make completely sure that you've got the connection pooling turned off is to check in the registry under:

HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST.INI\ XXXXXX  (where XXXXXX is the driver name.)

If Connection pooling is truely turned off there will not be a string value for CPTimeout.

The connection pooling should be managing itself.  Once you close the connection it should release it back into the pool & once the connection has reached its timeout (CPTimeout above...defaults to 60 seconds) its destroyed.  If your application appropriately disposes of all connections the connections will eventually be destroyed.  Using the performance monitor you can track this process.

An easy way to check & see if connections are actually being left open is by calling ReleaseObjectPool (System.Data.Odbc.Odbcconnection).  If any connections are still open calling this will do nothing.  However, if all connections are closed this call will destory any idle connections in the pool.

Hope this helps.  -Nick


   Report 
Post
CRINETA » .NET Discussion... » Tips, Tricks & ... » ODBC Connection Hangs on Close

Copyright Cedar Rapids INETA, 2005 All rights reserved.

Powered by Community Server, by Telligent Systems