Singleton + sqlConnection with inhereted winform

  • Thread starter Thread starter The Real Andy
  • Start date Start date
T

The Real Andy

OK, please excuse the simple (ambiguous) nature of this question.

I have a winform, set up as a base class. I inherit about 5 instances
from this form, each relating to a db table. Currently I am using some
code in a method that launches the inherited form. In this method I
check if an instance of the form already exists, and give focus if it
does exist. Is there an easier way? I figure if I can some how set up
a static method in the inherited form only, then I can create a
'DoesInstanceExist'method. I could do this, but is possible with an
inherited form, or will I have to override the method in each form?

The second question relates to sqlConnection. How can I make this
accessible in all inherited forms? I guess the more appropriate
question is how do you link dataAdaptors and dataSets in with it. I am
confusing myself now, cause I can half think of a way to do it and am
wondering why I am asking the question!
 
Checking for or finding an existing instance is a different concept than a
singleton, which is a class that will only ever allow one instance of
itself.

http://www.yoda.arachsys.com/csharp/singleton.html

Thanks for that. The sigleton pattern is what I was chasing. The way I
am doing things now is not the best. I guess what I was really asking
is how to do this with inherited forms. Each time I inherit the form,
it should be a singleton. Each inherited form does something
different, i just copy the visual style
 
Back
Top