Hi,
Am just making an admin type system for my shop, written in ASP. I have the store setting (E.g. show various areas of the site, min order value, meta tags etc etc) stored in my SQL Server database (the table is a simple two column table - Setting and SettingValue).
At the top of every page I obviously want to get the current value of each setting. As this action happens on every page I need to make sure I'm not doing anything silly and that I'm getting these settings in the most effecient way possible. I'm even more confused as my mate disagrees with whats the quickest way.
I'm currently using the following function to get the setting (the stored procedure is just the sql: select settingvalue from settings where settingname=somesettingname):
Personally, I think think this is the fastest method as I open a single recordset, get all the setting values (there will ultimately be around 30 or 40 setting values), store them in a variable and close the recordset.
Now my mate reckons that converting my above procedure to a function to return the setting (E.g. getSettingKey("RequiredSettingName") is quicker). This way, I'd have to call the function multiple times (opening and closing multiple recordsets) in if statements, I imagine would be slower. I think using one of my varaibles I got above is quicker.
So my code would be something like:
and his would be:
Any advice appreciated.
Thanks
Am just making an admin type system for my shop, written in ASP. I have the store setting (E.g. show various areas of the site, min order value, meta tags etc etc) stored in my SQL Server database (the table is a simple two column table - Setting and SettingValue).
At the top of every page I obviously want to get the current value of each setting. As this action happens on every page I need to make sure I'm not doing anything silly and that I'm getting these settings in the most effecient way possible. I'm even more confused as my mate disagrees with whats the quickest way.
I'm currently using the following function to get the setting (the stored procedure is just the sql: select settingvalue from settings where settingname=somesettingname):
Code:
Sub getSettingKey(theKey)
set ConnZ= server.createobject("ADODB.Connection")
ConnZ.Open strConn
set rsZ = ConnZ.Execute("EXECUTE spGetGLOBAL_SETTINGS " & theKey)
varSetting1 = rsZ("SettingValue1")
varSetting2 = rsZ("SettingValue3")
rsZ.Close
Set rsZ =Nothing
ConnZ.Close
Set ConnZ = Nothing
End Sub
Personally, I think think this is the fastest method as I open a single recordset, get all the setting values (there will ultimately be around 30 or 40 setting values), store them in a variable and close the recordset.
Now my mate reckons that converting my above procedure to a function to return the setting (E.g. getSettingKey("RequiredSettingName") is quicker). This way, I'd have to call the function multiple times (opening and closing multiple recordsets) in if statements, I imagine would be slower. I think using one of my varaibles I got above is quicker.
So my code would be something like:
Code:
'Sub to get all settings
If varSetting1 = 1 Then
'some html here
End If
If varSetting2 = 0 Then
'some html here
End If
and his would be:
Code:
If getSettingKey("settingname1") = 1 Then
'some html here
End If
If getSettingKey("settingname2") = 0 Then
'some html here
End If
Any advice appreciated.
Thanks