K
Ken Getz
Suppose I have a Function/Procedure like this:
Sub DoSomething()
Dim db As New SqlClient.SqlConnection(ConnectionString)
db.Open()
Dim cmd As New SqlClient.SqlCommand("Delete from emp where EmpID=1",
db)
cmd.ExecuteNonQuery()
db.Close
cmd.Dispose()
db.Dispose()
End Sub
In this procedure I have disposed the Connection object and Command Object
once I am done using it.
Do I have to do the dispose, or the garbase collector will take care of
this.
Is it a good practice to dispose objects once we are done using it.
Ken
Sub DoSomething()
Dim db As New SqlClient.SqlConnection(ConnectionString)
db.Open()
Dim cmd As New SqlClient.SqlCommand("Delete from emp where EmpID=1",
db)
cmd.ExecuteNonQuery()
db.Close
cmd.Dispose()
db.Dispose()
End Sub
In this procedure I have disposed the Connection object and Command Object
once I am done using it.
Do I have to do the dispose, or the garbase collector will take care of
this.
Is it a good practice to dispose objects once we are done using it.
Ken