Cerebrus
unread,May 28, 2009, 1:43:17 PM5/28/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Alright, here's my opinion:
The "Using" construct is functionally equivalent to a Try-Finally
construct. It is a developer convenience and the compiler will convert
the former to the latter. So, there is no difference in performance in
the two. However, the Try-Finally construct does not provide for a
structured way to handle exceptions (it omits the Catch block and all
exceptions are bubbled up to the calling code. This is the point you
need to consider... Does your code require all exceptions to be
handled here itself ? If so, you will have to refactor into Try-Catch-
Finally constructs. If not, you're good with using Using ! (pun
intended)
The code you presented is very well formed. It is hard to be more
efficient except for a single point that I noticed - You open the
Connection early on. For highest performance, you should open your
Connection as late as possible and dispose of it as soon as possible.
IOW, the Connection.Open() call should be just before the
SqlDataReader is created.