467,118 Members | 923 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,118 developers. It's quick & easy.

Sharing objects across forms and other objects

Hi,

What is the best method to share objects (such as a SqlConnection)
across many forms. I am currently passing the SqlConnection in to
other forms from the main form through the other forms' constructor.
This is becoming cumbersome when dealing with dozens of forms. What
are the alternatives?

Thanks in advance,
Evan
Nov 15 '05 #1
  • viewed: 1845
Share:
2 Replies
Set the connection as static, and access it using the
type.

Rakesh

-----Original Message-----
Hi,

What is the best method to share objects (such as a SqlConnection)across many forms. I am currently passing the SqlConnection in toother forms from the main form through the other forms' constructor.This is becoming cumbersome when dealing with dozens of forms. Whatare the alternatives?

Thanks in advance,
Evan
.

Nov 15 '05 #2
Hi evan,

You can create a class with static members for these escenario, you could
also use a singleton for this.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Evan" <ev**************@yahoo.com> wrote in message
news:8d**************************@posting.google.c om...
Hi,

What is the best method to share objects (such as a SqlConnection)
across many forms. I am currently passing the SqlConnection in to
other forms from the main form through the other forms' constructor.
This is becoming cumbersome when dealing with dozens of forms. What
are the alternatives?

Thanks in advance,
Evan

Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Alex | last post: by
4 posts views Thread by Cowboy \(Gregory A. Beamer\) | last post: by
2 posts views Thread by Mervin Williams | last post: by
1 post views Thread by Daryll SHatz | last post: by
4 posts views Thread by Martin Ehrlich | last post: by
45 posts views Thread by =?Utf-8?B?QmV0aA==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.