Sub InitializeDatabaseSettings()
'{{EA
On Error GoTo ErrorHandler
'}}EA
Dim bolConfigFileExists As Boolean
Set pobjFileS = New FileSystemObject
pstrConfigIniPath = App.Path & "\Bin\" & App.EXEName & ".ini"
MsgBox "This is the path of the ini file" & pstrConfigIniPath
bolConfigFileExists = pobjFileS.FileExists(pstrConfigIniPath)
MsgBox bolConfigFileExists
If bolConfigFileExists = False Then
Call modErrorHandler.ErrorTrap("999", "The System will shutdown. Cannot find the config file in the following path: " & pstrConfigIniPath & ". Please contact Balgord immediately with this issue.", pstrProjectTitle, "Main", "modMain")
Call CloseProject
End
End If
Call GetDatabaseSettings(bolConfigFileExists)
pstrConnectionString = "DSN=" & pstrDatabaseName & ";Uid=;Pwd="
'{{EA
ErrorHandler_Exit:
Screen.MousePointer = 0
Exit Sub
ErrorHandler:
Call modErrorHandler.ErrorTrap(Err.Number, Err.Description, Err.Source, "InitializeDatabaseSettings", "modMain")
GoTo ErrorHandler_Exit
'}}EA
End Sub
This is where it reads the ini file:
Sub GetDatabaseSettings(vbolConfigFileExists As Boolean)
'{{EA
On Error GoTo ErrorHandler
'}}EA
Dim strDate As String
Dim strTemp As String
Dim strSection As String
Dim objINI As New stsTools.clsToolsIni
If vbolConfigFileExists = False Then Exit Sub
MsgBox "Config File Exists"
strSection = "Database"
ptypDBSettings.pstrProvider = UCase(objINI.strGetFromIni(strSection, "Provider", pstrConfigIniPath))
ptypDBSettings.pstrServerName = UCase(objINI.strGetFromIni(strSection, "ServerName", pstrConfigIniPath))
ptypDBSettings.pstrDatabaseName = UCase(objINI.strGetFromIni(strSection, "DatabaseName", pstrConfigIniPath))
MsgBox "Database read from ini file"
strSection = "ACCPAC_Database"
ptypDBSettings.pstrProvider_ACCPAC = UCase(objINI.strGetFromIni(strSection, "Provider", pstrConfigIniPath))
ptypDBSettings.pstrServerName_ACCPAC = UCase(objINI.strGetFromIni(strSection, "ServerName", pstrConfigIniPath))
ptypDBSettings.pstrDatabaseName_ACCPAC = UCase(objINI.strGetFromIni(strSection, "DatabaseName", pstrConfigIniPath))
MsgBox "ACCPAC_Database read from ini file"
strSection = "ACCPAC"
ptypACCPACSettings.pstrVersion = UCase(objINI.strGetFromIni(strSection, "Version", pstrConfigIniPath))
ptypACCPACSettings.pstrAPPID = UCase(objINI.strGetFromIni(strSection, "APPID", pstrConfigIniPath))
ptypACCPACSettings.pstrProgramName = UCase(objINI.strGetFromIni(strSection, "ProgramName", pstrConfigIniPath))
MsgBox "ACCPAC section read from ini file"
strSection = "Project"
pstrProjectTitle = UCase(objINI.strGetFromIni(strSection, "Title", pstrConfigIniPath))
strSection = "Preference"
strTemp = UCase(objINI.strGetFromIni(strSection, "ShowSplashScreen", pstrConfigIniPath))
If strTemp = True Or strTemp = False Then
pbolShowSplashScreen = strTemp
Else
pbolShowSplashScreen = True
End If
strSection = "ErrorLog"
pstrErrProvider = UCase(objINI.strGetFromIni(strSection, "Provider", pstrConfigIniPath))
pstrErrDBPath = UCase(objINI.strGetFromIni(strSection, "Path", pstrConfigIniPath))
pstrErrEmail = UCase(objINI.strGetFromIni(strSection, "Email", pstrConfigIniPath))
MsgBox "ErrorLog read from ini file"
strSection = "Notes"
pstrNotesPath = UCase(objINI.strGetFromIni(strSection, "Path", pstrConfigIniPath))
MsgBox "Notes path from ini file"
'{{EA
ErrorHandler_Exit:
Screen.MousePointer = 0
Exit Sub
ErrorHandler:
Call modErrorHandler.ErrorTrap(Err.Number, Err.Description, Err.Source, "GetDatabaseSettings", "modMain")
GoTo ErrorHandler_Exit
'}}EA
End Sub
And this is the actual ini file:
; ====================================================
; THIS IS A STANDARD SECTION AND SHOULD BE FILLED OUT
; FOR EVERY PROGRAM BEING USED
; ====================================================
[Database]
Provider="{Pervasive ODBC Client Interface}"
ServerName="Balgord-14"
DatabaseName="BCODAT"
[ACCPAC_Database]
Provider="{Pervasive ODBC Client Interface}"
ServerName="Balgord-14"
DatabaseName="BCOQ"
[ACCPAC]
Version="54A"
APPID="GL"
ProgramName="GL0001"
[Project]
Title= [G/L Accounts]
[Preference]
ShowSplashScreen=false
[ErrorLog]
Provider=Microsoft.Jet.OLEDB.4.0
Path=C:\Program Files\Balgord\Database\ErrorLog.mdb
Email=test@test1.com
[Notes]
Path="\\Sbs-server\company\Projects\Notes.exe"
; ==================================================
; THIS IS A CUSTOM SECTION WHICH WILL CHANGE DEPENDING
; ON THE PROGRAM
; ==================================================