Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
shabazz5th
Starting Member
13 Posts |
Posted - 2009-01-14 : 13:35:22
|
Hey guysI have some code in a for each container and I want to store all the values in an object.My question is...I have a script embedded in this container, do all the variables get reset everytime it goes into the script?ie.' Add your code here ' Dim UploadRouteInformation As UploadRouteInformation = New UploadRouteInformation Dim lAccountBalances As AccountBalances = New AccountBalances 'Account Balance Dim oAccountBalance As AccountBalance = New AccountBalance Dim xmlABdate As New Cbl.Sa.HH.MMA.UploadData.XMLDateTime Dim xmlABbalance As New Cbl.Sa.HH.MMA.UploadData.XMLDecimal xmlABdate.Value = CDate("2008-01-01") xmlABbalance.Value = CDec(0.0) oAccountBalance.StoreId = "3025609" oAccountBalance.ClientModifyDt = xmlABdate oAccountBalance.BalanceAmt = xmlABbalance lAccountBalances.Add(oAccountBalance)I want to keep adding to lAccountBalances, but everytime it loops, it resets this value. It's almost like I need to store this in a global variable and keep adding to it.Not an easy task :(...any help? |
|
Nagaraj
Starting Member
14 Posts |
Posted - 2009-01-15 : 03:46:47
|
Hi Shabaaz,You are creating the AccountBalances object every time the loop runs. You need to create only once for the first time. To get desired result follow the steps below1. Create an integer variable at package level with default value 1.2. Retrieve the variable inside the script and create AccountBalances object only once as shown Dim lAccountBalances As AccountBalances If Dts.Variables["variable"].value == 1 Then lAccountBalances = New AccountBalances End IfHope this will solve your problem.Nagaraj. |
 |
|
|
|
|