Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

For Loop and variable

Status
Not open for further replies.

williey

Technical User
Jan 21, 2004
242
I have a boolean variable x (default = False) under the scope of For loop. what the for loop does is query a column and return the value to var x. In a script task, I check for if var x equal false, wait for 5 mins before executing again.

The problem is after the script task completes running, the value of var x changes to false.

What causes the var x to change?

------------------------------------------
There are 10 kinds of people in this world. One that understands binary and the other one that does not.
 
Unless you tell something to change the value, nothing will change it.

The only thing that I can think of is that the variable might be assigned to the SQL Script and not to the Loop?

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

My Blog
 
This is what the code looks like. I verified that both entering and exiting the script, the var did not change. It is upon control being pass back to For Loop that the value changes.

Code:
	Public Sub Main()
		'
		' Add your code here
        '
        Dim IsNoteLoaded As Boolean
        'Wait for 5 minutes
        MsgBox(Dts.Variables("NoteLoaded").Value)
        IsNoteLoaded = CBool(Dts.Variables("NoteLoaded").Value)
        If IsNoteLoaded = False Then
            System.Threading.Thread.Sleep(300000)
        End If
        MsgBox(Dts.Variables("NoteLoaded").Value)
        Dts.TaskResult = Dts.Results.Success
	End Sub

------------------------------------------
There are 10 kinds of people in this world. One that understands binary and the other one that does not.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top