StrataFrame Forum

Need a Value from a DB Table Available to All my Forms

http://forum.strataframe.net/Topic30410.aspx

By Terry Bottorff - 10/11/2011

I have a value stored in one of my DB Tables that I need available for all of my forms. Is there a way I could load the value as my Application loads and then have it Global or Shared for all of the rest of the App?
TIA.
By Edhy Rijo - 10/11/2011

Hi Terry,

I have a class named AppSettings.vb for this purpose and all you have to do is create a Public Shared ReadOnly property for your table's business object, then you can access your table fields via this property from anywhere in the application, here is part of my AppSettings.vb class:

Public Class AppSettings
 #Region " Constructor"
     Private Sub New()
     End Sub
 #End Region

 #Region " Public Shared Properties "
     '-- Set the Company Setting Object
     Public Shared ReadOnly Property Company() As bizCompany
         Get
             Using bo As New bizCompany
                 bo.FillAllRecords()
                 If bo.Count = 0 Then
                     bo.NewRow()
                     bo.Save()
                 End If
                 Return bo
             End Using
         End Get
     End Property
End Class

Then you use the Company's properties like this:
AppSettings.Company.CompanyName
AppSettings.Company.CompanyEmail
Enjoy!!!
By Terry Bottorff - 10/11/2011

Wow what a cool way to do this. Thank you so much. It's incredible how much you can do.
By Edhy Rijo - 10/11/2011

Terry Bottorff (10/11/2011)
Wow what a cool way to do this. Thank you so much. It's incredible how much you can do.

You are welcome, but I must say, everything I am able to do right now in my applications with SF & VB.NET is in part thanks to the great cooperation of many others in the SF forums like Trent, Ivan, Greg, Keith and many others that took their time to share with this community.  One way or another they all influence my way to see .Net coming from a VFP environment.
By Terry Bottorff - 10/12/2011

Yes everyone here deserves a Thumbs Up for the help they give.