Question : Find and Replace hundreds of  line of VBScript code via SQL statement

I’ve successfully been able to find and replace VBscript code via a SQL update statement, but it only works with one line of VBscript code. This statement is below

1:
2:
3:
update FormDefinitions set xaoProperties = replace(convert(varchar(max),xaoProperties), 'Spa Price','Spa Standard Price')
FROM [M1_TJ].[dbo].[FormDefinitions]
WHERE xaoFormID like '%fcy%' and xaoControlName like 'LBLSPAPRICE'


I need to replace a function with new code via SQL. The database table called FormDefinitions is as follows.
1:
2:
3:
4:
5:
6:
           (<xaoFormID, char(75),>
           ,<xaoControlName, char(70),>
           ,<xaoClassID, char(35),>
           ,<xaoType, numeric(1,0),>
           ,<xaoProperties, text,>
           ,<xaoCode, text,>)


I need to replace VBscript code in a function called UpdatePriceTag in the xaoCode datafield. However, I need to replace many lines of code. Old and new function is below.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
 ‘Old UpdatePriceTag function
Function UpdatePriceTag(cControlName,cPartID,cAsterisk)
	cPrefix = cAsterisk + Chr(13) + "$"
	Call RemovePriceTag(cControlName)
	If Right(Controls(cControlName).Caption,10) = "(Included)" Then
		Controls(cControlName).Caption = Left(Controls(cControlName).Caption,Len(Controls(cControlName).Caption)-Len(Chr(13) + "(Included)"))
	End If
	Set rsPrice = CreateObject("ADODB.Recordset")
	rsPrice.Open "select * from PartUnitSalePrices where imhpartid = " & App.AddQuotes(cPartID) & " and imhpartrevisionid = 'A' order by imhstartdate desc", Connection, adOpenStatic, adLockBatchOptimistic, adCmdText
	If Not rsPrice.EOF Then
		CPrice = CStr(Round(rsPrice.Fields("imhUnitSalePrice").Value,2))
		CPrice = cPrefix + AddCents(CPrice,True)
		Controls(cControlName).Caption = Controls(cControlName).Caption + CPrice
	End If
End Function


with this one below…

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
‘New UpdatePriceTag function
Function UpdatePriceTag(cControlName,cPartID,cAsterisk)
	cPrefix = cAsterisk + Chr(13) + "$"
	Call RemovePriceTag(cControlName)
	If Right(Controls(cControlName).Caption,10) = "(Included)" Then
		Controls(cControlName).Caption = Left(Controls(cControlName).Caption,Len(Controls(cControlName).Caption)-Len(Chr(13) + "(Included)"))
	End If
	Set rsPrice = CreateObject("ADODB.Recordset")
	rsPrice.Open "select * from PartUnitSalePrices where imhpartid = " & App.AddQuotes(cPartID) & " and imhpartrevisionid = 'A' order by imhstartdate desc", Connection, adOpenStatic, adLockBatchOptimistic, adCmdText
	If Not rsPrice.EOF Then
		If cPartID = "ATRALINTAS" Then
		CPrice = CStr(Round(rsPrice.Fields("imhUnitSalePrice").Value,2))
		Cprice = CDbl(CPrice)*cLintPots
		Cprice = CStr(CPrice)
		CPrice = cPrefix + AddCents(CPrice,True)
		Controls(cControlName).Caption = Controls(cControlName).Caption + CPrice
		Else
		CPrice = CStr(Round(rsPrice.Fields("imhUnitSalePrice").Value,2))
		CPrice = cPrefix + AddCents(CPrice,True)
		Controls(cControlName).Caption = Controls(cControlName).Caption + CPrice
		End If
	End If
End Function


I’d appreciate any feedback.

Thanks!! J

Answer : Find and Replace hundreds of  line of VBScript code via SQL statement

You could try using the jquery library and do something like this..
include jquery library in the html head

$(document).ready(function(){

$('input [type=hidden]').each(function(){   //captures and package all hidden elements
  value = $(this).value;    ///this  will get the value for each of the hidden elements  one at a time
    ///put ajax call here..  each hidden  element value will be processed one at a time ...loop
   });
});
Random Solutions  
 
programming4us programming4us