M
Max
This is the best method I've found to store and load settings from database.
I load the settings once at start as public variables. The method can be
called easily anytime you want to load the new settings from database.
Comments very welcome... I'd like to refine this... besides the error
handling I need to add for the db conn...
Global.asax ---------------
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim oAppConfig As New myWebAppName.AppConfig
oAppConfig.LoadSettings()
End Sub
AppConfig Class -------------------
Public Class AppConfig
Public Sub LoadSettings()
Dim strConnectionString = "hardcode here or use the web.config"
'some db code here...
AppVars.strMailTo = 'get from database code here
AppVars.strCompanyName = 'get from database code here
AppVars.strSomeOtherVar = 'get from database code here
'and so on...
End Sub
Public Sub StoreSettings()
'same idea here...
End Sub
End Class
AppVars Module - still debating on whether to use public class or module
since they are the same thing...
----------------------
Module AppVars
Public strMailTo
Public strCompanyName
Public strSomeOtherVar
End Module
-Max
I load the settings once at start as public variables. The method can be
called easily anytime you want to load the new settings from database.
Comments very welcome... I'd like to refine this... besides the error
handling I need to add for the db conn...
Global.asax ---------------
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim oAppConfig As New myWebAppName.AppConfig
oAppConfig.LoadSettings()
End Sub
AppConfig Class -------------------
Public Class AppConfig
Public Sub LoadSettings()
Dim strConnectionString = "hardcode here or use the web.config"
'some db code here...
AppVars.strMailTo = 'get from database code here
AppVars.strCompanyName = 'get from database code here
AppVars.strSomeOtherVar = 'get from database code here
'and so on...
End Sub
Public Sub StoreSettings()
'same idea here...
End Sub
End Class
AppVars Module - still debating on whether to use public class or module
since they are the same thing...
----------------------
Module AppVars
Public strMailTo
Public strCompanyName
Public strSomeOtherVar
End Module
-Max