Re: Static Method returns DataReader

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Varangian" <ofmars@xxxxxxxxx> wrote in message
news:1168252158.616128.20500@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I know that the kind of question below has been asked several
times....however I need a clear answer in my specific situation.

I have 2 methods. One returns an SqlDataReader and the other returns a
DataView. I was considering making them Static methods, so as to avoid
creating instance of the class which takes care of these methods, kind
of a helper class. Since its a web site the method may be accessed by
more than one user at one time....

Static methods which return ADO.NET objects are quite common in DALs
(database abstraction layers) - see the Microsoft DAAB for examples of
this...

the question is would it improve the performance if using Static method
in this case?

Not really - in fact, probably not at all...

Would it be a problem if using Static methods at all?

No, so long as you realise that any static variables will be shared across
multiple instances. This may or may not matter... E.g. if your site uses
only one SQL connection string, then it won't matter if it's shared across
multiple instances, as it will always be the same... However, if you have
other static variables which differ per session, then you will have serious
problems... :-)

All my DAL methods are static because it's a bit less coding not to have to
do class instantiation every time...


.



Relevant Pages

  • Re: Static Method returns DataReader
    ... so long as you realise that any static variables will be shared across ... This may or may not matter... ... multiple instances, as it will always be the same... ... All my DAL methods are static because it's a bit less coding not to have to ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: The Death of Carbon
    ... are in contention or are contrary to the comment: ... than one app running, no matter if the person is only working in one. ... Heck, a lot of people have multiple instances of, ...
    (comp.sys.mac.advocacy)
  • Re: ATL EXE global data
    ... I suspect it's simply poor design. ... A set of classes communicate ... via static variables instead of directly, but the whole set has to ... >> to be common across multiple instances of the exe also. ...
    (microsoft.public.vc.atl)
  • Re: Running to separate instances of IE
    ... multiple instances when you do that? ... It appears that no matter how many ... siljaline wrote: ... Gary L. Smith ...
    (microsoft.public.windows.inetexplorer.ie6.browser)