I'm new to dotNetand want to know whether connection created for an MDI parent form can be used by all of its child forms without recreating connections. Many thanks. Derry
Breifly it is a way to ensure that your object has only a single instance...
Public Class MyClass Private m_Singleton as object Public Function MySingleton as object If IsNothing(m_Singleton) then m_Singleton = New Object return m_Singleton else return m_Singleton end if end function end class
Might not be the best design, but it is possible yes.
Expose the Connection as a public property. You MDI children, assuming their immediate parent is the MDI Parent form, will need to cast the Parent property to Your form to access it.
You could also use a Singleton model to expose this connection to everybody.
Connection String (MDI forms)
Jalal Y. Marzouq
http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnbda/html/singletondespatt.asp
Breifly it is a way to ensure that your object has only a single instance...
Public Class MyClass
Private m_Singleton as object
Public Function MySingleton as object
If IsNothing(m_Singleton) then
m_Singleton = New Object
return m_Singleton
else
return m_Singleton
end if
end function
end class
John Hensley
Expose the Connection as a public property. You MDI children, assuming their immediate parent is the MDI Parent form, will need to cast the Parent property to Your form to access it.
You could also use a Singleton model to expose this connection to everybody.
Chris D Jones
Many thanks