Is it alright if I took a static class that wrapped around a
SQLConnection object on a web application? Or should I make it an
instance class?

If I have a static class, would there be just one code instance of the
class in the server process/app domain for all the clients/browsers?
So, if a page on a particular request/context does a
MyConnectionClass.Close() in its Unload event handler for the Page,
would this close the connection for all clients if it were implemented
as a static class?

Re: Connection as a static class by Cor

Cor
Thu Sep 01 02:41:03 CDT 2005

Water Cooler,

Keep in mind that a Static Class belongs in an ASPNET situation to all
active clients at that moment.

Not the best place to put your connection used by one client in my opinion.

Just my thought,

Cor



Re: Connection as a static class by W

W
Thu Sep 01 08:36:55 CDT 2005

Like Cor mentions, I'd avoid it here. statics belong to every single user
of an asp.net application like he says, unlike Winforms where they just
belong to the individual user. Just make sure connection pooling is on and
that you ALWAYS close your connections (ie use try/catch/finally and/or
using{ } statements
"Water Cooler v2" <wtr_clr@yahoo.com> wrote in message
news:1125543317.150282.121150@f14g2000cwb.googlegroups.com...
> Is it alright if I took a static class that wrapped around a
> SQLConnection object on a web application? Or should I make it an
> instance class?
>
> If I have a static class, would there be just one code instance of the
> class in the server process/app domain for all the clients/browsers?
> So, if a page on a particular request/context does a
> MyConnectionClass.Close() in its Unload event handler for the Page,
> would this close the connection for all clients if it were implemented
> as a static class?
>



Re: Connection as a static class by WJ

WJ
Thu Sep 01 14:33:23 CDT 2005

The best source code that you can learn from is the MS/Data Application API
Block (DAAB). It uses "singleton" class and it is working fine in an Asp.Net
web applications.

You may want to do more reasearch on singleton here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ImpSingletonInCsharp.asp

John