DB_SettingRead + DB_SettingSave + ...

Reads/Saves specific settings from DB table
Mainly for Classic ASP, but can be used inside VBA
Table Columns are ...
ID | SettingName | SettingValue | SettingValue2 | Description | DateAdded
Needs connection already defined and functions DB_Read1stRow, CutString3 for Classic ASP
Or DB_Connect_AndOr_Fix for VBA

Function DB_SettingRead(SettingName)
' Reads specific settings from DB table
Rett = DB_SettingRead_Row(SettingName , "{||}")
DB_SettingRead = CutString3(Rett, 3, "{||}")
End Function

Sub DB_SettingSave(SettingName, SettingNewValue)
' Saves specific setting into Settings table
'
SQL2 = "Insert into dbo.Settings(SettingName,SettingValue,SettingVakue2,Description,DateAdded) Values('" & SettingName & "','" & SettingNewValue & "','','','" & DateinSQL & "')"
Found1 = DB_SettingRead(SettingName)
If Found1 > "" Then SQL2 = "Update dbo.Settings Set SettingValue='" & _
SettingNewValue & "' where SettingName like '" & SettingName & "'"
 connection.execute(SQL2)
' For VBA, use ... DB_Connect_AndOr_Fix SQL2
End Sub

Function DB_SettingRead_Value2(SettingName)
' Reads Value2 of specific settings from DB table
Rett = DB_SettingRead_Row(SettingName , "{||}")
DB_SettingRead_Value2 = CutString3(Rett, 4, "{||}")
End Function
Sub DB_SettingSave_Value2(SettingName, SettingNewValue2)
End Sub
Function DB_SettingRead_Description(SettingName)
' Reads Value2 of specific settings from DB table
Rett = DB_SettingRead_Row(SettingName , "{||}")
DB_SettingRead_Description = CutString3(Rett, 5, "{||}")
End Function
Sub DB_SettingSave_Description(SettingName, SettingNewDescription)
End Sub

Function DB_SettingRead_Row(SettingName, Sepa)
' Reads full row for certain settings from DB table
 ' Table Columns are ...
 ' ID | SettingName | SettingValue | SettingValue2 | Description | DateAdded
Rett = ""
If Sepa = "" Then Sepa = "{||}"
SQL1 = "Select * from dbo.Settings where SettingName like '" & SettingName & "' "
Rett = DB_Read1stRow(SQL1, Sepa)
DB_SettingRead_Row = Rett
End Function

SettingName
or
SettingName, SettingNewValue

Views 343 Downloads 151

'DB_Read1stRow', 'CutString3', 'DB_Connect_AndOr_Fix', 'DB', 'Database', 'Setting', 'Settings', 'ANStr', 'ANString', 'ANStrList'

ANmarAmdeen
323
Database Classic ASP
Revisions

v2.0