SQLDataSource Connections Not Closing Maxing out Connection Pool on SQL Server

I have been using the SQLDatasource object througout this project and believe it is the source of my connections maxing out.   It seems the SQLDatasource object does not automatically disconnect the connection.  I use several SQLDatasources on various pages and I believe this is the source of my problem.   My questions is how do you manually code this to force the SQLDatasource connection to close?     I am thinking it might be best to stay away from this object, even though it is a very useful tool, but I am thinking it may not be the best solution for larger scale projects.    Any feedback on this topic would be greatly appreciated.
jholmes0724Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Alfred A.Connect With a Mentor Commented:
Hi,

Also, here is another one that discuss about SQLDataSource Dispose within EE.

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_25136140.html

I hope you understand now what I was trying to convey awhile ago.
0
 
Alfred A.Commented:
Hi,

Have you tried doing,

Conn.Close()
Conn.Dispose()
0
 
Alfred A.Commented:
Hi,

Additional comment, be sure to close all objects using the sqldatasource before doing a dispose.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Alfred A.Commented:
Hi,

Just an example by the way, if you have a data reader using a SQLDataSource, you need to close the data reader first before doing a dispose.

For example,

DR.Close()
.....

SQLDataSource1.Dispose()
0
 
jholmes0724Author Commented:
I don't think just disposing the SQLDatasource closes the connection.   The whole point of the SQLDatasource is that it contains the connection, datareader, and sql in one container.  Its not like when you use the SQL.Data.SQLClient objects and define those on your own.  So your answer seems to be more about using those objects.   I am refering to the SQLDataSource object.  Do you understand what I mean?
0
 
Alfred A.Commented:
Hi,

Yes, I understand what you meant.  So what I meant awhile ago is for you to deal whatever that refers to the SQLDataSource and then dispose SQLDataSource.

Check this out, it might help:

http://forums.asp.net/p/1275516/2436239.aspx#2436239
0
 
jholmes0724Author Commented:
Thanks, This does seem to work.  Thanks so much.
0
All Courses

From novice to tech pro — start learning today.