ErrorHandling...Try, Catch and Finally...easy question.
OK, I have the following:
VB Code:
Public Sub Fetch()
Dim Svr As UserSvr 'This is my own created data access class
Dim DS As DataSet
Dim Row As DataRow
Try
Svr = New UserSvr
DS = Svr.Fetch
For Each Row In DS.Tables.Item("Users").Rows
Add(CStr(Row.Item("Username")), CStr(Row.Item("Email")), CStr(Row.Item("Telephone")), False) 'Cbln(Row.Item("Administrator")))
Next
Catch ex As Exception
MsgBox(ex.Message)
Finally
Row = Nothing
Svr = Nothing
DS = Nothing
End Try
End Sub
Now I am using a DataSet here passed up from the DA Layer, but that's irrelevant here.
Now. In the FINALLY section of the Try thingy I clean up my objects, which seems fair enough. However, while I am populating my classes with data from the dataset, in the For Next loop, I still have a reference to to server DA object (SVR)...So should my code be modified to:
[VBOCDE]
Try
Svr = New UserSvr
DS = Svr.Fetch
Svr = Nothing
[/Highlight]
So I have the line of code:
twice...once in the TRY section and once in the FINALLY section
Although doing the aboce still keeps it open coz of garbage collection....what would you do here?
Woof