Sql close connection issue....

  • Thread starter Thread starter lee atkinson
  • Start date Start date
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
 
Ok cool ... Theres no issues in passing the sqlcomm to a function like i've
done then?
 
Back
Top