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


Author
Message
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
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.
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
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!!!


Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Wow what a cool way to do this. Thank you so much. It's incredible how much you can do.
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
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.

Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)Advanced StrataFrame User (778 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
Yes everyone here deserves a Thumbs Up for the help they give.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search