dbTalk Databases Forums  

Help Needed understanding the Problem

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Help Needed understanding the Problem in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Peter Newman
 
Posts: n/a

Default Help Needed understanding the Problem - 08-04-2004 , 04:21 AM






Im runnung SQL 2000 on Windows 2003 Server

I have a simple DTS that loops through files in a directory and imports them into a table. It then deletes the files

Step 1 - ActiveX
Loops through and gets the firat filename, and assigns it to a global variable
Step 2 - Dynamic Properties task
Set the TextFile Source to the Global Variable holding the file name
Step 3 - Data Driven Query
Update the table with data from the file
Step 4 - Deletes the file and resets the global variable for the filename to "". Then loops back to step 1

this works fine on the first loop, but on the second loop it fails on step 3 stating the source file is not found. Im at a loss as i know the global variable is showing a valid filename and that file exists. Is there a way to set the source property directly from axtive x ? maybe that will cure the problem





Reply With Quote
  #2  
Old   
Jacco Schalkwijk
 
Posts: n/a

Default Re: Help Needed understanding the Problem - 08-04-2004 , 05:07 AM






The method as described in http://www.sqldts.com/?246 has worked well for
me. That doesn't use a dynamic properties task, but sets the source via an
ActiveX script.

--
Jacco Schalkwijk
SQL Server MVP


"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote

Quote:
Im runnung SQL 2000 on Windows 2003 Server

I have a simple DTS that loops through files in a directory and imports
them into a table. It then deletes the files

Step 1 - ActiveX
Loops through and gets the firat filename, and assigns it to a global
variable
Step 2 - Dynamic Properties task
Set the TextFile Source to the Global Variable holding the file name
Step 3 - Data Driven Query
Update the table with data from the file
Step 4 - Deletes the file and resets the global variable for the filename
to "". Then loops back to step 1

this works fine on the first loop, but on the second loop it fails on step
3 stating the source file is not found. Im at a loss as i know the global
variable is showing a valid filename and that file exists. Is there a way
to set the source property directly from axtive x ? maybe that will cure
the problem







Reply With Quote
  #3  
Old   
Peter Newman
 
Posts: n/a

Default Re: Help Needed understanding the Problem - 08-04-2004 , 06:17 AM



Jacco,

Thanks, that has helped a little. I'm managing to set the Text file ( Source) Data Source to the correct file name, but am still having problems setting the SourceObjectName on the Data Driven Query

"Jacco Schalkwijk" wrote:

Quote:
The method as described in http://www.sqldts.com/?246 has worked well for
me. That doesn't use a dynamic properties task, but sets the source via an
ActiveX script.

--
Jacco Schalkwijk
SQL Server MVP


"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in message
news:412A01BD-F5F6-4202-9049-3EB93A8F6990 (AT) microsoft (DOT) com...
Im runnung SQL 2000 on Windows 2003 Server

I have a simple DTS that loops through files in a directory and imports
them into a table. It then deletes the files

Step 1 - ActiveX
Loops through and gets the firat filename, and assigns it to a global
variable
Step 2 - Dynamic Properties task
Set the TextFile Source to the Global Variable holding the file name
Step 3 - Data Driven Query
Update the table with data from the file
Step 4 - Deletes the file and resets the global variable for the filename
to "". Then loops back to step 1

this works fine on the first loop, but on the second loop it fails on step
3 stating the source file is not found. Im at a loss as i know the global
variable is showing a valid filename and that file exists. Is there a way
to set the source property directly from axtive x ? maybe that will cure
the problem








Reply With Quote
  #4  
Old   
Darren Green
 
Posts: n/a

Default Re: Help Needed understanding the Problem - 08-04-2004 , 07:19 AM



Here is rough example of how to set the SourceObjectName in script, showing
the collections and objects you go through-

DTSGlobalvariables.Parent.Tasks("DDQTaskName").Cus tomTask.SourceObjectName =
"Fred"


--
Darren Green
http://www.sqldts.com
"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote

Quote:
Jacco,

Thanks, that has helped a little. I'm managing to set the Text file (
Source) Data Source to the correct file name, but am still having problems
setting the SourceObjectName on the Data Driven Query
Quote:
"Jacco Schalkwijk" wrote:

The method as described in http://www.sqldts.com/?246 has worked well
for
me. That doesn't use a dynamic properties task, but sets the source via
an
ActiveX script.

--
Jacco Schalkwijk
SQL Server MVP


"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in message
news:412A01BD-F5F6-4202-9049-3EB93A8F6990 (AT) microsoft (DOT) com...
Im runnung SQL 2000 on Windows 2003 Server

I have a simple DTS that loops through files in a directory and
imports
them into a table. It then deletes the files

Step 1 - ActiveX
Loops through and gets the firat filename, and assigns it to a global
variable
Step 2 - Dynamic Properties task
Set the TextFile Source to the Global Variable holding the file name
Step 3 - Data Driven Query
Update the table with data from the file
Step 4 - Deletes the file and resets the global variable for the
filename
to "". Then loops back to step 1

this works fine on the first loop, but on the second loop it fails on
step
3 stating the source file is not found. Im at a loss as i know the
global
variable is showing a valid filename and that file exists. Is there a
way
to set the source property directly from axtive x ? maybe that will
cure
the problem










Reply With Quote
  #5  
Old   
Peter Newman
 
Posts: n/a

Default Re: Help Needed understanding the Problem - 08-04-2004 , 07:39 AM



Darren, ive tried that but get the same results.
maybe if i post the code, someone might spot where im going wrong

Step 1 - Active x


Function Main()

Dim pkg
Dim stpUpdateQuery
Dim stpFinished
Dim stpResetLoop

Set pkg = DTSGlobalVariables.Parent
Set stpUpdateQuery = pkg.steps("DTSStep_DTSDataDrivenQueryTask_1")
Set stpFinished = pkg.steps("DTSStep_DTSActiveScriptTask_4")
Set stpResetLoop = pkg.steps("DTSStep_DTSActiveScriptTask_5")

' Ensure all steps are disables to start with
stpUpdateQuery.DisableStep = True
stpFinished.DisableStep = True
stpResetLoop.Disablestep = True

' Check to see if any files exist
IF ShouldILoop = True Then
DTSGlobalVariables("gv_DTSRunning").Value = 1
stpUpdateQuery.DisableStep = False
stpResetLoop.DisableStep = False
stpUpdateQuery.ExecutionStatus = DTSStepExecStat_Waiting
Main = DTSTaskExecResult_Success
exit function
Else
stpFinished.DisableStep = False
stpFinished.ExecutionStatus = DTSStepExecStat_Waiting
Main = DTSTaskExecResult_Success
exit function
End if



End Function


Function ShouldILoop

dim fso
dim fil
dim fold
dim pkg
dim counter
Dim conTextFile

set pkg = DTSGlobalVariables.Parent
set fso = CREATEOBJECT("Scripting.FileSystemObject")
set fold = fso.GetFolder(DTSGlobalVariables("gv_FileLocation" ).Value)
counter = fold.files.count
Set conTextFile = pkg.Connections("FileSource")

'So long as there is more than 1 file carry on

IF counter = 1 then
for each fil in fold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.path
ShouldILoop = CBool(True)
next
ELSEIF counter > 1 then
for each fil in fold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.path
ShouldILoop = CBool(True)
Next
ELSEIF counter = 0 then
ShouldILoop = CBool(False)
exit function
End if

conTextFile.DataSource = DTSGlobalVariables("gv_FileFullName").Value
DTSGlobalvariables.Parent.Tasks("DTSTask_DTSDataDr ivenQueryTask_1").CustomTask.SourceObjectName = DTSGlobalVariables("gv_FileFullName").Value

End Function


Step 2 is the Data driven Query

Step 3 - Active x

Function Main()

Dim pkg
Dim stpStartLoop
Dim fso



Set pkg = DTSGlobalVariables.Parent
Set stpStartLoop = pkg.steps("DTSStep_DTSActiveScriptTask_3")
Set fso = CreateObject("Scripting.FileSystemobject")
stpstartloop.Disablestep = True

' Delete the file
fso.DeleteFile DTSGlobalVariables("gv_FileFullName").Value
Set fso = nothing
DTSGlobalVariables("gv_FileFullName").Value = ""

DTSGlobalvariables.Parent.Tasks("DTSTask_DTSDataDr ivenQueryTask_1").CustomTask.SourceObjectName = ""

stpStartloop.Disablestep = False
stpStartloop.ExecutionStatus = DTSStepExecStat_Waiting
set pkg = nothing

Main = DTSTaskExecResult_Success
End Function


I know its not pretty, but then again im more of an amateur at this. Whats happining is if i run the DTS, it completes 1 loop without a problem, but on the second pass, although it gets the correct filenam, the DDQ fails stating the file does not exist, how ever I can execute each step in turn and complete several 'loops' without a problem. I am at a loss as to why it wont run

Thanks for any help


"Darren Green" wrote:

Quote:
Here is rough example of how to set the SourceObjectName in script, showing
the collections and objects you go through-

DTSGlobalvariables.Parent.Tasks("DDQTaskName").Cus tomTask.SourceObjectName =
"Fred"


--
Darren Green
http://www.sqldts.com
"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in message
news:A2900D6F-D618-422A-991E-83A7F8A27583 (AT) microsoft (DOT) com...
Jacco,

Thanks, that has helped a little. I'm managing to set the Text file (
Source) Data Source to the correct file name, but am still having problems
setting the SourceObjectName on the Data Driven Query

"Jacco Schalkwijk" wrote:

The method as described in http://www.sqldts.com/?246 has worked well
for
me. That doesn't use a dynamic properties task, but sets the source via
an
ActiveX script.

--
Jacco Schalkwijk
SQL Server MVP


"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in message
news:412A01BD-F5F6-4202-9049-3EB93A8F6990 (AT) microsoft (DOT) com...
Im runnung SQL 2000 on Windows 2003 Server

I have a simple DTS that loops through files in a directory and
imports
them into a table. It then deletes the files

Step 1 - ActiveX
Loops through and gets the firat filename, and assigns it to a global
variable
Step 2 - Dynamic Properties task
Set the TextFile Source to the Global Variable holding the file name
Step 3 - Data Driven Query
Update the table with data from the file
Step 4 - Deletes the file and resets the global variable for the
filename
to "". Then loops back to step 1

this works fine on the first loop, but on the second loop it fails on
step
3 stating the source file is not found. Im at a loss as i know the
global
variable is showing a valid filename and that file exists. Is there a
way
to set the source property directly from axtive x ? maybe that will
cure
the problem











Reply With Quote
  #6  
Old   
Darren Green
 
Posts: n/a

Default Re: Help Needed understanding the Problem - 08-04-2004 , 08:23 AM



Quick guess, have you checked close connection on completion on the tasks
that use any connection which can changed during execution? If the
connection is open, and you change it's properties they do not take effect
as the task already has a copy of the info, so doesn't bother looking again
hence any changes are missed.

--
Darren Green
http://www.sqldts.com

"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote

Quote:
Darren, ive tried that but get the same results.
maybe if i post the code, someone might spot where im going wrong

Step 1 - Active x


Function Main()

Dim pkg
Dim stpUpdateQuery
Dim stpFinished
Dim stpResetLoop

Set pkg = DTSGlobalVariables.Parent
Set stpUpdateQuery = pkg.steps("DTSStep_DTSDataDrivenQueryTask_1")
Set stpFinished = pkg.steps("DTSStep_DTSActiveScriptTask_4")
Set stpResetLoop = pkg.steps("DTSStep_DTSActiveScriptTask_5")

' Ensure all steps are disables to start with
stpUpdateQuery.DisableStep = True
stpFinished.DisableStep = True
stpResetLoop.Disablestep = True

' Check to see if any files exist
IF ShouldILoop = True Then
DTSGlobalVariables("gv_DTSRunning").Value = 1
stpUpdateQuery.DisableStep = False
stpResetLoop.DisableStep = False
stpUpdateQuery.ExecutionStatus = DTSStepExecStat_Waiting
Main = DTSTaskExecResult_Success
exit function
Else
stpFinished.DisableStep = False
stpFinished.ExecutionStatus = DTSStepExecStat_Waiting
Main = DTSTaskExecResult_Success
exit function
End if



End Function


Function ShouldILoop

dim fso
dim fil
dim fold
dim pkg
dim counter
Dim conTextFile

set pkg = DTSGlobalVariables.Parent
set fso = CREATEOBJECT("Scripting.FileSystemObject")
set fold = fso.GetFolder(DTSGlobalVariables("gv_FileLocation" ).Value)
counter = fold.files.count
Set conTextFile = pkg.Connections("FileSource")

'So long as there is more than 1 file carry on

IF counter = 1 then
for each fil in fold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.path
ShouldILoop = CBool(True)
next
ELSEIF counter > 1 then
for each fil in fold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.path
ShouldILoop = CBool(True)
Next
ELSEIF counter = 0 then
ShouldILoop = CBool(False)
exit function
End if

conTextFile.DataSource = DTSGlobalVariables("gv_FileFullName").Value

DTSGlobalvariables.Parent.Tasks("DTSTask_DTSDataDr ivenQueryTask_1").CustomTa
sk.SourceObjectName = DTSGlobalVariables("gv_FileFullName").Value
Quote:
End Function


Step 2 is the Data driven Query

Step 3 - Active x

Function Main()

Dim pkg
Dim stpStartLoop
Dim fso



Set pkg = DTSGlobalVariables.Parent
Set stpStartLoop = pkg.steps("DTSStep_DTSActiveScriptTask_3")
Set fso = CreateObject("Scripting.FileSystemobject")
stpstartloop.Disablestep = True

' Delete the file
fso.DeleteFile DTSGlobalVariables("gv_FileFullName").Value
Set fso = nothing
DTSGlobalVariables("gv_FileFullName").Value = ""


DTSGlobalvariables.Parent.Tasks("DTSTask_DTSDataDr ivenQueryTask_1").CustomTa
sk.SourceObjectName = ""
Quote:
stpStartloop.Disablestep = False
stpStartloop.ExecutionStatus = DTSStepExecStat_Waiting
set pkg = nothing

Main = DTSTaskExecResult_Success
End Function


I know its not pretty, but then again im more of an amateur at this. Whats
happining is if i run the DTS, it completes 1 loop without a problem, but on
the second pass, although it gets the correct filenam, the DDQ fails stating
the file does not exist, how ever I can execute each step in turn and
complete several 'loops' without a problem. I am at a loss as to why it
wont run
Quote:
Thanks for any help


"Darren Green" wrote:

Here is rough example of how to set the SourceObjectName in script,
showing
the collections and objects you go through-


DTSGlobalvariables.Parent.Tasks("DDQTaskName").Cus tomTask.SourceObjectName =
"Fred"


--
Darren Green
http://www.sqldts.com
"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in message
news:A2900D6F-D618-422A-991E-83A7F8A27583 (AT) microsoft (DOT) com...
Jacco,

Thanks, that has helped a little. I'm managing to set the Text file (
Source) Data Source to the correct file name, but am still having
problems
setting the SourceObjectName on the Data Driven Query

"Jacco Schalkwijk" wrote:

The method as described in http://www.sqldts.com/?246 has worked
well
for
me. That doesn't use a dynamic properties task, but sets the source
via
an
ActiveX script.

--
Jacco Schalkwijk
SQL Server MVP


"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in
message
news:412A01BD-F5F6-4202-9049-3EB93A8F6990 (AT) microsoft (DOT) com...
Im runnung SQL 2000 on Windows 2003 Server

I have a simple DTS that loops through files in a directory and
imports
them into a table. It then deletes the files

Step 1 - ActiveX
Loops through and gets the firat filename, and assigns it to a
global
variable
Step 2 - Dynamic Properties task
Set the TextFile Source to the Global Variable holding the file
name
Step 3 - Data Driven Query
Update the table with data from the file
Step 4 - Deletes the file and resets the global variable for the
filename
to "". Then loops back to step 1

this works fine on the first loop, but on the second loop it fails
on
step
3 stating the source file is not found. Im at a loss as i know
the
global
variable is showing a valid filename and that file exists. Is
there a
way
to set the source property directly from axtive x ? maybe that
will
cure
the problem













Reply With Quote
  #7  
Old   
Peter Newman
 
Posts: n/a

Default Re: Help Needed understanding the Problem - 08-04-2004 , 08:37 AM



Darren,

Im lost now, can you explain the close conection and how and where i should be doing this as i havent a clue

"Darren Green" wrote:

Quote:
Quick guess, have you checked close connection on completion on the tasks
that use any connection which can changed during execution? If the
connection is open, and you change it's properties they do not take effect
as the task already has a copy of the info, so doesn't bother looking again
hence any changes are missed.

--
Darren Green
http://www.sqldts.com

"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in message
news:91898552-3396-4ABB-B06F-BF79DC05DF5E (AT) microsoft (DOT) com...
Darren, ive tried that but get the same results.
maybe if i post the code, someone might spot where im going wrong

Step 1 - Active x


Function Main()

Dim pkg
Dim stpUpdateQuery
Dim stpFinished
Dim stpResetLoop

Set pkg = DTSGlobalVariables.Parent
Set stpUpdateQuery = pkg.steps("DTSStep_DTSDataDrivenQueryTask_1")
Set stpFinished = pkg.steps("DTSStep_DTSActiveScriptTask_4")
Set stpResetLoop = pkg.steps("DTSStep_DTSActiveScriptTask_5")

' Ensure all steps are disables to start with
stpUpdateQuery.DisableStep = True
stpFinished.DisableStep = True
stpResetLoop.Disablestep = True

' Check to see if any files exist
IF ShouldILoop = True Then
DTSGlobalVariables("gv_DTSRunning").Value = 1
stpUpdateQuery.DisableStep = False
stpResetLoop.DisableStep = False
stpUpdateQuery.ExecutionStatus = DTSStepExecStat_Waiting
Main = DTSTaskExecResult_Success
exit function
Else
stpFinished.DisableStep = False
stpFinished.ExecutionStatus = DTSStepExecStat_Waiting
Main = DTSTaskExecResult_Success
exit function
End if



End Function


Function ShouldILoop

dim fso
dim fil
dim fold
dim pkg
dim counter
Dim conTextFile

set pkg = DTSGlobalVariables.Parent
set fso = CREATEOBJECT("Scripting.FileSystemObject")
set fold = fso.GetFolder(DTSGlobalVariables("gv_FileLocation" ).Value)
counter = fold.files.count
Set conTextFile = pkg.Connections("FileSource")

'So long as there is more than 1 file carry on

IF counter = 1 then
for each fil in fold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.path
ShouldILoop = CBool(True)
next
ELSEIF counter > 1 then
for each fil in fold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.path
ShouldILoop = CBool(True)
Next
ELSEIF counter = 0 then
ShouldILoop = CBool(False)
exit function
End if

conTextFile.DataSource = DTSGlobalVariables("gv_FileFullName").Value

DTSGlobalvariables.Parent.Tasks("DTSTask_DTSDataDr ivenQueryTask_1").CustomTa
sk.SourceObjectName = DTSGlobalVariables("gv_FileFullName").Value

End Function


Step 2 is the Data driven Query

Step 3 - Active x

Function Main()

Dim pkg
Dim stpStartLoop
Dim fso



Set pkg = DTSGlobalVariables.Parent
Set stpStartLoop = pkg.steps("DTSStep_DTSActiveScriptTask_3")
Set fso = CreateObject("Scripting.FileSystemobject")
stpstartloop.Disablestep = True

' Delete the file
fso.DeleteFile DTSGlobalVariables("gv_FileFullName").Value
Set fso = nothing
DTSGlobalVariables("gv_FileFullName").Value = ""


DTSGlobalvariables.Parent.Tasks("DTSTask_DTSDataDr ivenQueryTask_1").CustomTa
sk.SourceObjectName = ""

stpStartloop.Disablestep = False
stpStartloop.ExecutionStatus = DTSStepExecStat_Waiting
set pkg = nothing

Main = DTSTaskExecResult_Success
End Function


I know its not pretty, but then again im more of an amateur at this. Whats
happining is if i run the DTS, it completes 1 loop without a problem, but on
the second pass, although it gets the correct filenam, the DDQ fails stating
the file does not exist, how ever I can execute each step in turn and
complete several 'loops' without a problem. I am at a loss as to why it
wont run

Thanks for any help


"Darren Green" wrote:

Here is rough example of how to set the SourceObjectName in script,
showing
the collections and objects you go through-


DTSGlobalvariables.Parent.Tasks("DDQTaskName").Cus tomTask.SourceObjectName =
"Fred"


--
Darren Green
http://www.sqldts.com
"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in message
news:A2900D6F-D618-422A-991E-83A7F8A27583 (AT) microsoft (DOT) com...
Jacco,

Thanks, that has helped a little. I'm managing to set the Text file (
Source) Data Source to the correct file name, but am still having
problems
setting the SourceObjectName on the Data Driven Query

"Jacco Schalkwijk" wrote:

The method as described in http://www.sqldts.com/?246 has worked
well
for
me. That doesn't use a dynamic properties task, but sets the source
via
an
ActiveX script.

--
Jacco Schalkwijk
SQL Server MVP


"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in
message
news:412A01BD-F5F6-4202-9049-3EB93A8F6990 (AT) microsoft (DOT) com...
Im runnung SQL 2000 on Windows 2003 Server

I have a simple DTS that loops through files in a directory and
imports
them into a table. It then deletes the files

Step 1 - ActiveX
Loops through and gets the firat filename, and assigns it to a
global
variable
Step 2 - Dynamic Properties task
Set the TextFile Source to the Global Variable holding the file
name
Step 3 - Data Driven Query
Update the table with data from the file
Step 4 - Deletes the file and resets the global variable for the
filename
to "". Then loops back to step 1

this works fine on the first loop, but on the second loop it fails
on
step
3 stating the source file is not found. Im at a loss as i know
the
global
variable is showing a valid filename and that file exists. Is
there a
way
to set the source property directly from axtive x ? maybe that
will
cure
the problem














Reply With Quote
  #8  
Old   
Darren Green
 
Posts: n/a

Default Re: Help Needed understanding the Problem - 08-04-2004 , 10:07 AM



Right-click a task, select Workflow, Workflow Properties, Options - See the
check box.

This closes the connection after the task completes. If a connection is
already in use any changes will not be "read", as this only happens when it
is opened. To ensure the connection is opened for each iteration of your
package loop, and hence the new settings are "read" you can force a close
with this option.

Make sense?


--
Darren Green
http://www.sqldts.com

"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote

Quote:
Darren,

Im lost now, can you explain the close conection and how and where i
should be doing this as i havent a clue

"Darren Green" wrote:

Quick guess, have you checked close connection on completion on the
tasks
that use any connection which can changed during execution? If the
connection is open, and you change it's properties they do not take
effect
as the task already has a copy of the info, so doesn't bother looking
again
hence any changes are missed.

--
Darren Green
http://www.sqldts.com

"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in message
news:91898552-3396-4ABB-B06F-BF79DC05DF5E (AT) microsoft (DOT) com...
Darren, ive tried that but get the same results.
maybe if i post the code, someone might spot where im going wrong

Step 1 - Active x


Function Main()

Dim pkg
Dim stpUpdateQuery
Dim stpFinished
Dim stpResetLoop

Set pkg = DTSGlobalVariables.Parent
Set stpUpdateQuery = pkg.steps("DTSStep_DTSDataDrivenQueryTask_1")
Set stpFinished = pkg.steps("DTSStep_DTSActiveScriptTask_4")
Set stpResetLoop = pkg.steps("DTSStep_DTSActiveScriptTask_5")

' Ensure all steps are disables to start with
stpUpdateQuery.DisableStep = True
stpFinished.DisableStep = True
stpResetLoop.Disablestep = True

' Check to see if any files exist
IF ShouldILoop = True Then
DTSGlobalVariables("gv_DTSRunning").Value = 1
stpUpdateQuery.DisableStep = False
stpResetLoop.DisableStep = False
stpUpdateQuery.ExecutionStatus = DTSStepExecStat_Waiting
Main = DTSTaskExecResult_Success
exit function
Else
stpFinished.DisableStep = False
stpFinished.ExecutionStatus = DTSStepExecStat_Waiting
Main = DTSTaskExecResult_Success
exit function
End if



End Function


Function ShouldILoop

dim fso
dim fil
dim fold
dim pkg
dim counter
Dim conTextFile

set pkg = DTSGlobalVariables.Parent
set fso = CREATEOBJECT("Scripting.FileSystemObject")
set fold = fso.GetFolder(DTSGlobalVariables("gv_FileLocation" ).Value)
counter = fold.files.count
Set conTextFile = pkg.Connections("FileSource")

'So long as there is more than 1 file carry on

IF counter = 1 then
for each fil in fold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.path
ShouldILoop = CBool(True)
next
ELSEIF counter > 1 then
for each fil in fold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.path
ShouldILoop = CBool(True)
Next
ELSEIF counter = 0 then
ShouldILoop = CBool(False)
exit function
End if

conTextFile.DataSource = DTSGlobalVariables("gv_FileFullName").Value


DTSGlobalvariables.Parent.Tasks("DTSTask_DTSDataDr ivenQueryTask_1").CustomTa
sk.SourceObjectName = DTSGlobalVariables("gv_FileFullName").Value

End Function


Step 2 is the Data driven Query

Step 3 - Active x

Function Main()

Dim pkg
Dim stpStartLoop
Dim fso



Set pkg = DTSGlobalVariables.Parent
Set stpStartLoop = pkg.steps("DTSStep_DTSActiveScriptTask_3")
Set fso = CreateObject("Scripting.FileSystemobject")
stpstartloop.Disablestep = True

' Delete the file
fso.DeleteFile DTSGlobalVariables("gv_FileFullName").Value
Set fso = nothing
DTSGlobalVariables("gv_FileFullName").Value = ""



DTSGlobalvariables.Parent.Tasks("DTSTask_DTSDataDr ivenQueryTask_1").CustomTa
sk.SourceObjectName = ""

stpStartloop.Disablestep = False
stpStartloop.ExecutionStatus = DTSStepExecStat_Waiting
set pkg = nothing

Main = DTSTaskExecResult_Success
End Function


I know its not pretty, but then again im more of an amateur at this.
Whats
happining is if i run the DTS, it completes 1 loop without a problem,
but on
the second pass, although it gets the correct filenam, the DDQ fails
stating
the file does not exist, how ever I can execute each step in turn and
complete several 'loops' without a problem. I am at a loss as to why it
wont run

Thanks for any help


"Darren Green" wrote:

Here is rough example of how to set the SourceObjectName in script,
showing
the collections and objects you go through-



DTSGlobalvariables.Parent.Tasks("DDQTaskName").Cus tomTask.SourceObjectName =
"Fred"


--
Darren Green
http://www.sqldts.com
"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in
message
news:A2900D6F-D618-422A-991E-83A7F8A27583 (AT) microsoft (DOT) com...
Jacco,

Thanks, that has helped a little. I'm managing to set the Text
file (
Source) Data Source to the correct file name, but am still having
problems
setting the SourceObjectName on the Data Driven Query

"Jacco Schalkwijk" wrote:

The method as described in http://www.sqldts.com/?246 has worked
well
for
me. That doesn't use a dynamic properties task, but sets the
source
via
an
ActiveX script.

--
Jacco Schalkwijk
SQL Server MVP


"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in
message
news:412A01BD-F5F6-4202-9049-3EB93A8F6990 (AT) microsoft (DOT) com...
Im runnung SQL 2000 on Windows 2003 Server

I have a simple DTS that loops through files in a directory
and
imports
them into a table. It then deletes the files

Step 1 - ActiveX
Loops through and gets the firat filename, and assigns it to
a
global
variable
Step 2 - Dynamic Properties task
Set the TextFile Source to the Global Variable holding the
file
name
Step 3 - Data Driven Query
Update the table with data from the file
Step 4 - Deletes the file and resets the global variable for
the
filename
to "". Then loops back to step 1

this works fine on the first loop, but on the second loop it
fails
on
step
3 stating the source file is not found. Im at a loss as i
know
the
global
variable is showing a valid filename and that file exists. Is
there a
way
to set the source property directly from axtive x ? maybe
that
will
cure
the problem
















Reply With Quote
  #9  
Old   
jeromet
 
Posts: n/a

Default Re: Help Needed understanding the Problem - 01-25-2005 , 08:13 PM



I am having a the same dts looping problem. I checked "close connection on
completion" and do not get the error, but the the job ends. Does something
else need changed?

"Peter Newman" wrote:

Quote:
Darren,

Thanks, it makes perfect sense.. and it's solved my problem.

Pete

"Darren Green" wrote:

Right-click a task, select Workflow, Workflow Properties, Options - See the
check box.

This closes the connection after the task completes. If a connection is
already in use any changes will not be "read", as this only happens when it
is opened. To ensure the connection is opened for each iteration of your
package loop, and hence the new settings are "read" you can force a close
with this option.

Make sense?


--
Darren Green
http://www.sqldts.com

"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in message
news:0E947060-8F7C-4242-BC61-0024750E2A0D (AT) microsoft (DOT) com...
Darren,

Im lost now, can you explain the close conection and how and where i
should be doing this as i havent a clue

"Darren Green" wrote:

Quick guess, have you checked close connection on completion on the
tasks
that use any connection which can changed during execution? If the
connection is open, and you change it's properties they do not take
effect
as the task already has a copy of the info, so doesn't bother looking
again
hence any changes are missed.

--
Darren Green
http://www.sqldts.com

"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in message
news:91898552-3396-4ABB-B06F-BF79DC05DF5E (AT) microsoft (DOT) com...
Darren, ive tried that but get the same results.
maybe if i post the code, someone might spot where im going wrong

Step 1 - Active x


Function Main()

Dim pkg
Dim stpUpdateQuery
Dim stpFinished
Dim stpResetLoop

Set pkg = DTSGlobalVariables.Parent
Set stpUpdateQuery = pkg.steps("DTSStep_DTSDataDrivenQueryTask_1")
Set stpFinished = pkg.steps("DTSStep_DTSActiveScriptTask_4")
Set stpResetLoop = pkg.steps("DTSStep_DTSActiveScriptTask_5")

' Ensure all steps are disables to start with
stpUpdateQuery.DisableStep = True
stpFinished.DisableStep = True
stpResetLoop.Disablestep = True

' Check to see if any files exist
IF ShouldILoop = True Then
DTSGlobalVariables("gv_DTSRunning").Value = 1
stpUpdateQuery.DisableStep = False
stpResetLoop.DisableStep = False
stpUpdateQuery.ExecutionStatus = DTSStepExecStat_Waiting
Main = DTSTaskExecResult_Success
exit function
Else
stpFinished.DisableStep = False
stpFinished.ExecutionStatus = DTSStepExecStat_Waiting
Main = DTSTaskExecResult_Success
exit function
End if



End Function


Function ShouldILoop

dim fso
dim fil
dim fold
dim pkg
dim counter
Dim conTextFile

set pkg = DTSGlobalVariables.Parent
set fso = CREATEOBJECT("Scripting.FileSystemObject")
set fold = fso.GetFolder(DTSGlobalVariables("gv_FileLocation" ).Value)
counter = fold.files.count
Set conTextFile = pkg.Connections("FileSource")

'So long as there is more than 1 file carry on

IF counter = 1 then
for each fil in fold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.path
ShouldILoop = CBool(True)
next
ELSEIF counter > 1 then
for each fil in fold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.path
ShouldILoop = CBool(True)
Next
ELSEIF counter = 0 then
ShouldILoop = CBool(False)
exit function
End if

conTextFile.DataSource = DTSGlobalVariables("gv_FileFullName").Value


DTSGlobalvariables.Parent.Tasks("DTSTask_DTSDataDr ivenQueryTask_1").CustomTa
sk.SourceObjectName = DTSGlobalVariables("gv_FileFullName").Value

End Function


Step 2 is the Data driven Query

Step 3 - Active x

Function Main()

Dim pkg
Dim stpStartLoop
Dim fso



Set pkg = DTSGlobalVariables.Parent
Set stpStartLoop = pkg.steps("DTSStep_DTSActiveScriptTask_3")
Set fso = CreateObject("Scripting.FileSystemobject")
stpstartloop.Disablestep = True

' Delete the file
fso.DeleteFile DTSGlobalVariables("gv_FileFullName").Value
Set fso = nothing
DTSGlobalVariables("gv_FileFullName").Value = ""



DTSGlobalvariables.Parent.Tasks("DTSTask_DTSDataDr ivenQueryTask_1").CustomTa
sk.SourceObjectName = ""

stpStartloop.Disablestep = False
stpStartloop.ExecutionStatus = DTSStepExecStat_Waiting
set pkg = nothing

Main = DTSTaskExecResult_Success
End Function


I know its not pretty, but then again im more of an amateur at this.
Whats
happining is if i run the DTS, it completes 1 loop without a problem,
but on
the second pass, although it gets the correct filenam, the DDQ fails
stating
the file does not exist, how ever I can execute each step in turn and
complete several 'loops' without a problem. I am at a loss as to why it
wont run

Thanks for any help


"Darren Green" wrote:

Here is rough example of how to set the SourceObjectName in script,
showing
the collections and objects you go through-



DTSGlobalvariables.Parent.Tasks("DDQTaskName").Cus tomTask.SourceObjectName =
"Fred"


--
Darren Green
http://www.sqldts.com
"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in
message
news:A2900D6F-D618-422A-991E-83A7F8A27583 (AT) microsoft (DOT) com...
Jacco,

Thanks, that has helped a little. I'm managing to set the Text
file (
Source) Data Source to the correct file name, but am still having
problems
setting the SourceObjectName on the Data Driven Query

"Jacco Schalkwijk" wrote:

The method as described in http://www.sqldts.com/?246 has worked
well
for
me. That doesn't use a dynamic properties task, but sets the
source
via
an
ActiveX script.

--
Jacco Schalkwijk
SQL Server MVP


"Peter Newman" <PeterNewman (AT) discussions (DOT) microsoft.com> wrote in
message
news:412A01BD-F5F6-4202-9049-3EB93A8F6990 (AT) microsoft (DOT) com...
Im runnung SQL 2000 on Windows 2003 Server

I have a simple DTS that loops through files in a directory
and
imports
them into a table. It then deletes the files

Step 1 - ActiveX
Loops through and gets the firat filename, and assigns it to
a
global
variable
Step 2 - Dynamic Properties task
Set the TextFile Source to the Global Variable holding the
file
name
Step 3 - Data Driven Query
Update the table with data from the file
Step 4 - Deletes the file and resets the global variable for
the
filename
to "". Then loops back to step 1

this works fine on the first loop, but on the second loop it
fails
on
step
3 stating the source file is not found. Im at a loss as i
know
the
global
variable is showing a valid filename and that file exists. Is
there a
way
to set the source property directly from axtive x ? maybe
that
will
cure
the problem

















Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.