Sql close connection issue....

L

lee atkinson

HI Guys,

Having a bit of an issue with our web application speed , just checking
whether this routine actually closes the connection properly? Ive checked
the open connections with QA using sp_who2 and the number of connections
seems ok

Any thoughts?

So I do a normal sql command as normal ... Open the connection , do a query

Dim sqlcomm As New SqlClient.SqlCommand(sql.ToString, tools.openconn)

blah blah

sqlcomm.ExecuteNonQuery()

' then I use this to close
tools.closeconn(sqlcomm)


''''then I have this sub in a utility class to get the connection by ref and
then close it....


Public Shared Sub closeconn(ByRef sqlcomm As SqlCommand)
sqlcomm.Connection.Close()
sqlcomm.Connection.Dispose()
sqlcomm.Connection = Nothing
sqlcomm.Dispose()
sqlcomm = Nothing
End Sub



This look ok to you ? No problems with how I do this?

Cheers
lee
 
L

lee atkinson

Ok cool ... Theres no issues in passing the sqlcomm to a function like i've
done then?
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top