Try...catch...finally question

  • Thread starter Thread starter dord
  • Start date Start date
D

dord

Try
DB_DataAdapter.Fill(dt)
Return dt
Catch ex As Exception
Console.WriteLine(ex.ToString)
Finally
DB_Command.Dispose()
DB_DataAdapter.Dispose()
End Try

The above code is within a function call, will it execute the Finally
section, even there is a Return in Try section?

Please help.
Thanks
 
Yep. This is what I always do:

Public Function DoSomething() As Boolean
Try
...
Return True
Catch ex As Exception
Return False
Finally
...
End Try

Crouchie1998
BA (HONS) MCP MCSE
 
Back
Top