ASP.NET to SQL Server

A

androoo

Im trying to run a health check on some new processes developed.

The bind method on list control seems to open a new database thread..

When i run sp_who on sql server it lists the new process as sleeping,
awaiting command.

Are these threads eating up resources or getting in the way of any new
threads or will they be pooled ?

Anyone have any experience here to share please ?

Appreciate any help..

Andy
 
B

Brock Allen

As long as you've written your code to open the connection, get the data/data
bind, then close the connection you should be ok. It's no different than
any other DB access could you'd write (independant of ASP.NET).
 
A

androoo

Well the conenction is not explicitly closed when it returns a Sql,
here is the code im using:

Dim strConnStr As String

strConnStr = ConfigurationSettings.AppSettings("connString")
Dim objConn As New SqlConnection(strConnStr)

Try

Dim objCmd As New SqlCommand(strSQL, objConn)
Dim strHTML As String
objConn.Open()
GetRecordset =
objCmd.ExecuteReader(CommandBehavior.CloseConnection)

Catch objError As Exception
Dim objErr As clsErrors
objErr = objErr.GetInstance
objErr.CreateLogFiles()
objErr.ErrorLog("Error occurred in Get recordset " &
objError.Message & Chr(13) & strSQL)
End Try

Its just suprised me that the bind method opens a new instance of a
database thread each time its called...I thought that a sleeping object
would be reused in the pool, anyone see anything i might be doing
wrong?
 
J

jasonkester

Sure. You never call objConn.Close().

That connection will happily remain open as it goes out of scope, then
at some time in the future (from 1ms to 3 days), the garbage collector
will get around to recycling it for you, at which point it will be
closed and killed. If you explicitly close it, you'll at least sever
the connection to the database while you're waiting around for the
garbage collector.

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,212
Latest member
BrennaCaba

Latest Threads

Top