>***************************************************************************************** >* AddSetting() : Add a Configuration Setting * Wrapper for the My.Settings.Add() Method >***************************************************************************************** >PROCEDURE AddSetting > LPARAMETERS SettingType, SettingName, SettingValue > ** SettingType denotes local or global > LOCAL My as My > My = this.oConfig > > ** Return False and exit the method is any parameter is null > DO CASE > CASE EMPTY(SettingType) = .t. > RETURN .f. > CASE EMPTY(SettingName) = .t. > RETURN .f. > CASE EMPTY(SettingValue) = .t. > RETURN .f. > ENDCASE > > ** Execute for local Settings > IF ALLTRIM(UPPER(SettingType)) == "LOCAL" > LOCAL AddedSetting > AddedSetting = My.Settings.Add((SettingName), (SettingValue)) > my.Settings.Save(this.ConfigFile) > RETURN AddedSetting > ELSE > ** Execute for Global Settings (Settings table of the back end Database) > > ENDIF >ENDPROC >>
> ***************************************************************************************** >* DbConnect() : Connects to the remote database * >***************************************************************************************** >PROCEDURE DbConnect > this.DbConnectionHandle = SQLSTRINGCONNECT(this.oConfig.Settings.ConnectionString1) > > ** Check for for success (> -1) > IF this.DbConnectionHandle < 0 > RETURN .f. > ELSE > RETURN .t. > ENDIF >ENDPROC > > > > ***************************************************************************************** >* DbDisconnect() : Disconnects from the remote database * >***************************************************************************************** >PROCEDURE DbDisconnect > LOCAL DbDiscon > > DbDiscon = SQLDISCONNECT(This.DbConnectionHandle) > > > ** Check for Disconnection Errors > DO CASE > CASE DbDiscon = 1 && Success > this.DbConnectionHandle = -1 > && set the oApp.DbConnectionHandle property to -1 indicating no active connection > RETURN .t. > > CASE DbDiscon = -1 && Connection Level Error > ** Add Code to handle a failed Disconnect!!! > ** !!! > ** !!! > RETURN .f. > > CASE DbDiscon = -2 && Environmental Level Error > ** Add Code to handle a failed Disconnect!!! > ** !!! > ** !!! > RETURN .f. > ENDCASE >ENDPROC > > > ***************************************************************************************** >* DbExec() : Executes a SQL Command against the remote Database. * >***************************************************************************************** >PROCEDURE DbExec > LPARAMETERS DbCommand, CursorName > > ** Return False (error) for a missing parameter > IF EMPTY(DbCommand) = .t. > > ** Paramteter failure message ** > IF _Vfp.StartMode = 0 && dev environment > WAIT WINDOW "Sql Parameter Failure" > ELSE > **!!!! Run time Error > ENDIF > > RETURN .f. > ENDIF > > IF EMPTY(CursorName) > CursorName = "SqlResult" > ENDIF > > ** Execute the command against the remote database > LOCAL DbExecValue, ReturnValue > IF this.DbConnect() = .t. > DbExecValue = SQLEXEC(this.DbConnectionHandle, DbCommand, Cursorname) > ELSE > ** Sql Connection Error ** > IF _Vfp.StartMode = 0 && dev environment > WAIT WINDOW "Connection Level Error" > ELSE > ** Run time Error > ENDIF > > RETURN .f. && failed database connection > ENDIF > > IF DbExecValue = -1 > ReturnValue = .f. > ELSE > ReturnValue = .t. > ENDIF > > This.DbDisconnect() > > RETURN ReturnValue >ENDPROC > >>