Yes it is possible to share connections. But do remember that ADO.NET will
pool the connections for you automatically, and in most cases it makes sense
to let ADO.NET pool the connections for you rather than you pooling them
yourself. It could be argued that for a winforms app connection pooling is
uneccessary but I digress especially because by not connection pooling you
lock yourself in a bad architecture that prevents you from remtoing part of
your application to an app server and sharing connections in a database
layer over there as the demands of your application continue to grow.
Even if you were to pool the *instance* of the connection object, you'd only
be pooling the instance, not the underlying connections (which is what you
really want to do). To do that you'd have to explicitly disable connection
pooling.
Now if you still insist on sharing connections, you'd have to expose the
connection objects from this form as public variables and let the other form
access them via an instance of this form. If it is an MDI application or
similar, it may make sense to keep these connections as the logical
equivalence of global variables on the main parent form and pass the
references to the child forms.
- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
"hcs" <a@a.co.uk> wrote in message
news:ek**************@TK2MSFTNGP14.phx.gbl...
Hello,
i have got a form working which displays data from an access database. is
it possible to share the connections, dataadapter and datasets that have been
setup in this form on another form???
Cheers