dbTalk Databases Forums  

dts loop problem

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


Discuss dts loop problem in the microsoft.public.sqlserver.dts forum.



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

Default dts loop problem - 06-25-2004 , 03:53 AM






I've created a loop in a DTS, which retrieves connection information from a SQL table and then (is supposed to) populates tables in different Databases.

The loop works, but it keeps updating the same DB, rather than updating each of the individual DBs. The connection information seems to be updating each time the loop goes around, but the data isn't going into the correct DB.

any ideas?


code:
using the ideas from:

http://www.sqldts.com/default.aspx?213
http://www.sqldts.com/default.aspx?214,2


'************************************************* *********************
' Start of Loop
'************************************************* ***********************

Function Main()

set oPackage = DTSGlobalVariables.parent
set stpEnterLoop = oPackage.Steps("DTSStep_DTSExecuteSQLTask_1") 'Insert table
set stpFinished = oPackage.Steps("DTSStep_DTSExecuteSQLTask_17") 'Finish

Dim oRS
Set oRS = DTSGlobalVariables("RSRetailers").Value

If not oRS.EOF Then

stpEnterLoop.DisableStep = False
stpFinished.DisableStep = True
stpEnterLoop.ExecutionStatus = DTSStepExecStat_Waiting

msgbox oRS.Fields(3).Value


for each packageConn in oPackage.connections
if packageConn.ProviderID = "SQLOLEDB" then
if packageConn.Name = "SQL Connection" then
packageConn.datasource = oRS.Fields(2).Value
packageConn.Catalog = oRS.Fields(3).Value
packageConn.UserId = oRS.Fields(4).Value
packageConn.Password = oRS.Fields(5).Value
end if
end if
next


oRS.MoveNext

else
stpEnterLoop.DisableStep =True
stpFinished.DisableStep = False
stpFinished.ExecutionStatus = DTSStepExecStat_Waiting
End if

Set oRS = Nothing

Main = DTSTaskExecResult_Success
End Function







'************************************************* *********************
' Loop Around
'************************************************* ***********************

Function Main()

set pkg = DTSGlobalVariables.Parent
set stpbegin = pkg.Steps("DTSStep_DTSActiveScriptTask_3")
stpbegin.ExecutionStatus = DTSStepExecStat_Waiting

Main = DTSTaskExecResult_Success
End Function






---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: dts loop problem - 06-25-2004 , 04:26 AM






Make sure you have set "Close Connection on Completion" in the workflow
properties of the step

--

----------------------------

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


<aengusd> wrote

Quote:
I've created a loop in a DTS, which retrieves connection information from
a SQL table and then (is supposed to) populates tables in different
Databases.
Quote:
The loop works, but it keeps updating the same DB, rather than updating
each of the individual DBs. The connection information seems to be updating
each time the loop goes around, but the data isn't going into the correct
DB.
Quote:
any ideas?


code:
using the ideas from:

http://www.sqldts.com/default.aspx?213
http://www.sqldts.com/default.aspx?214,2


'************************************************* *********************
' Start of Loop
'************************************************* ***********************

Function Main()

set oPackage = DTSGlobalVariables.parent
set stpEnterLoop = oPackage.Steps("DTSStep_DTSExecuteSQLTask_1") 'Insert
table
set stpFinished = oPackage.Steps("DTSStep_DTSExecuteSQLTask_17") 'Finish

Dim oRS
Set oRS = DTSGlobalVariables("RSRetailers").Value

If not oRS.EOF Then

stpEnterLoop.DisableStep = False
stpFinished.DisableStep = True
stpEnterLoop.ExecutionStatus = DTSStepExecStat_Waiting

msgbox oRS.Fields(3).Value


for each packageConn in oPackage.connections
if packageConn.ProviderID = "SQLOLEDB" then
if packageConn.Name = "SQL Connection" then
packageConn.datasource = oRS.Fields(2).Value
packageConn.Catalog = oRS.Fields(3).Value
packageConn.UserId = oRS.Fields(4).Value
packageConn.Password = oRS.Fields(5).Value
end if
end if
next


oRS.MoveNext

else
stpEnterLoop.DisableStep =True
stpFinished.DisableStep = False
stpFinished.ExecutionStatus = DTSStepExecStat_Waiting
End if

Set oRS = Nothing

Main = DTSTaskExecResult_Success
End Function







'************************************************* *********************
' Loop Around
'************************************************* ***********************

Function Main()

set pkg = DTSGlobalVariables.Parent
set stpbegin = pkg.Steps("DTSStep_DTSActiveScriptTask_3")
stpbegin.ExecutionStatus = DTSStepExecStat_Waiting

Main = DTSTaskExecResult_Success
End Function






---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine
supports Post Alerts, Ratings, and Searching.




Reply With Quote
  #3  
Old   
aengusd
 
Posts: n/a

Default Re: dts loop problem - 06-25-2004 , 04:33 AM



Thanks Allan - that worked.

That's a pint I owe you!
Aengus

Quote:
-----Original Message-----
Make sure you have set "Close Connection on Completion"
in the workflow
properties of the step

--

----------------------------

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


aengusd> wrote

I've created a loop in a DTS, which retrieves
connection information from
a SQL table and then (is supposed to) populates tables in
different
Databases.

The loop works, but it keeps updating the same DB,
rather than updating
each of the individual DBs. The connection information
seems to be updating
each time the loop goes around, but the data isn't going
into the correct
DB.

any ideas?


code:
using the ideas from:

http://www.sqldts.com/default.aspx?213
http://www.sqldts.com/default.aspx?214,2


'************************************************* ******
***************
' Start of Loop
'************************************************* ******
*****************

Function Main()

set oPackage = DTSGlobalVariables.parent
set stpEnterLoop = oPackage.Steps
("DTSStep_DTSExecuteSQLTask_1") 'Insert
table
set stpFinished = oPackage.Steps
("DTSStep_DTSExecuteSQLTask_17") 'Finish

Dim oRS
Set oRS = DTSGlobalVariables("RSRetailers").Value

If not oRS.EOF Then

stpEnterLoop.DisableStep = False
stpFinished.DisableStep = True
stpEnterLoop.ExecutionStatus = DTSStepExecStat_Waiting

msgbox oRS.Fields(3).Value


for each packageConn in oPackage.connections
if packageConn.ProviderID = "SQLOLEDB" then
if packageConn.Name = "SQL Connection" then
packageConn.datasource = oRS.Fields(2).Value
packageConn.Catalog = oRS.Fields(3).Value
packageConn.UserId = oRS.Fields(4).Value
packageConn.Password = oRS.Fields(5).Value
end if
end if
next


oRS.MoveNext

else
stpEnterLoop.DisableStep =True
stpFinished.DisableStep = False
stpFinished.ExecutionStatus = DTSStepExecStat_Waiting
End if

Set oRS = Nothing

Main = DTSTaskExecResult_Success
End Function







'************************************************* ******
***************
' Loop Around
'************************************************* ******
*****************

Function Main()

set pkg = DTSGlobalVariables.Parent
set stpbegin = pkg.Steps
("DTSStep_DTSActiveScriptTask_3")
stpbegin.ExecutionStatus = DTSStepExecStat_Waiting

Main = DTSTaskExecResult_Success
End Function






---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.SqlJunkies.com/newsgroups Our
newsgroup engine
supports Post Alerts, Ratings, and Searching.


.


Reply With Quote
  #4  
Old   
PK
 
Posts: n/a

Default Re: dts loop problem - 07-06-2004 , 11:06 PM



hi...could you guide me how to do to dts loop...


<aengusd> wrote

Quote:
I've created a loop in a DTS, which retrieves connection information from
a SQL table and then (is supposed to) populates tables in different
Databases.
Quote:
The loop works, but it keeps updating the same DB, rather than updating
each of the individual DBs. The connection information seems to be updating
each time the loop goes around, but the data isn't going into the correct
DB.
Quote:
any ideas?


code:
using the ideas from:

http://www.sqldts.com/default.aspx?213
http://www.sqldts.com/default.aspx?214,2


'************************************************* *********************
' Start of Loop
'************************************************* ***********************

Function Main()

set oPackage = DTSGlobalVariables.parent
set stpEnterLoop = oPackage.Steps("DTSStep_DTSExecuteSQLTask_1") 'Insert
table
set stpFinished = oPackage.Steps("DTSStep_DTSExecuteSQLTask_17") 'Finish

Dim oRS
Set oRS = DTSGlobalVariables("RSRetailers").Value

If not oRS.EOF Then

stpEnterLoop.DisableStep = False
stpFinished.DisableStep = True
stpEnterLoop.ExecutionStatus = DTSStepExecStat_Waiting

msgbox oRS.Fields(3).Value


for each packageConn in oPackage.connections
if packageConn.ProviderID = "SQLOLEDB" then
if packageConn.Name = "SQL Connection" then
packageConn.datasource = oRS.Fields(2).Value
packageConn.Catalog = oRS.Fields(3).Value
packageConn.UserId = oRS.Fields(4).Value
packageConn.Password = oRS.Fields(5).Value
end if
end if
next


oRS.MoveNext

else
stpEnterLoop.DisableStep =True
stpFinished.DisableStep = False
stpFinished.ExecutionStatus = DTSStepExecStat_Waiting
End if

Set oRS = Nothing

Main = DTSTaskExecResult_Success
End Function







'************************************************* *********************
' Loop Around
'************************************************* ***********************

Function Main()

set pkg = DTSGlobalVariables.Parent
set stpbegin = pkg.Steps("DTSStep_DTSActiveScriptTask_3")
stpbegin.ExecutionStatus = DTSStepExecStat_Waiting

Main = DTSTaskExecResult_Success
End Function






---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine
supports Post Alerts, Ratings, and Searching.




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.