[thelist] comparing multiple values in VBScript

Ken Schaefer Ken at adOpenStatic.com
Thu Dec 1 23:51:00 CST 2005

Why don't you just update all the fields, and avoid the "checking" code

Or is there a reason you are checking all these values?


-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Canfield, Joel
Sent: Friday, 2 December 2005 11:15 AM
To: thelist at lists.evolt.org
Subject: [thelist] comparing multiple values in VBScript

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 & ")"




More information about the thelist mailing list