[thelist] comparing multiple values in VBScript
Canfield, Joel
JCanfield at PacAdvantage.org
Thu Dec 1 18:14:58 CST 2005
Our HelpDesk work order update tool is based on a form that calls
itself, checking for changed fields to update in the db (MSSQL)
There are 17 changeable fields, and currently, I'm looping through each
field, comparing the current value I've gathered from the db to the new
value submitted by the form. Any changed values are concatenated onto
strings which ultimately form the db update query.
There has to be a more efficient way, right?
Here's a bit of code for two of the 17 fields:
If Not(strCVTASK = strNewTASK) Then
strFields = strFields & ", TASK"
strValues = strValues & ", '" & strNewTASK & "'"
End If
If Not(strCVTYPE = strNewTYPE) Then
strFields = strFields & ", TYPE"
strValues = strValues & ", '" & strNewTYPE & "'"
End If
and they all get strung together here:
"insert into TASKS (" & strFields & ") values (" & strValues & ")"
Ideas?
thanks
joel
More information about the thelist
mailing list