dbTalk Databases Forums  

DTS Loop thru Multiple Datapump Sources

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


Discuss DTS Loop thru Multiple Datapump Sources in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bb_43@hotmail.com
 
Posts: n/a

Default DTS Loop thru Multiple Datapump Sources - 01-09-2004 , 09:55 PM






Using code examples from sqldts.com, I'm trying to use the same datapump task
to import data from multiple source databases, ito a single db.
All of this occurs on the same server.

The code snippet below will loop thru once for each entry in the companyinfo
table, and the connection object shows the correct database each time.
But the data always comes from the first database .
The msgbox shows the correct database, and the rpf increments correctly.

Any Ideas?





'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()
DIM connLocal
DIM rs1
dim strSQL
dim oPKG
dim oConnection

'instantiate DTS objects
Set oPKG =DTSGlobalVariables.Parent
set stpEnterLoop = opkg.Steps("DTSStep_DTSDataPumpTask_1")
set stpFinished = opkg.Steps("DTSStep_DTSActiveScriptTask_2")
stpEnterLoop.DisableStep=True

' instantiate the ADO objects
set connLocal = CreateObject("ADODB.Connection")
connLocal.ConnectionTimeout=45
connLocal.CommandTimeout=90
set rs1 = CreateObject("ADODB.Recordset")



'LoadSite
connLocal.Open = "Provider=SQLOLEDB.1;Data Source=MMSMainVS; Initial
Catalog=RMX10;Application Name='GetPICs';Integrated Security='SSPI'"
strSQL="Select top 1 companyid,companyname,DBName from companyinfo where
active= 1 and companyID<95 and companyID >"
strSQL=strSQL & DTSGlobalVariables("RPF").value
strSQL=strSQL & " order by companyid"
rs1.open strSQL,connLocal
IF not rs1.eof THEN
Set oConnection = oPKG.Connections("SiteData")
oConnection.Catalog = rs1.fields(2)

DTSGlobalVariables("RPF")=rs1.fields(0)
msgbox(oConnection.Catalog & " " & DTSGlobalVariables("RPF").value)
stpFinished.DisableStep=TRUE
stpEnterLoop.DisableStep=FALSE
stpEnterLoop.ExecutionStatus=DTSStepExecStat_Waiti ng

END IF
IF rs1.EOF THEN
stpFinished.DisableStep=FALSE
stpEnterLoop.DisableStep=TRUE
stpFinished.ExecutionStatus=DTSStepExecStat_Waitin g
END IF
rs1.close
conn.close
Main=DTSTaskExecResult_Success


End Function

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

Default Re: DTS Loop thru Multiple Datapump Sources - 01-10-2004 , 12:18 AM






Are you setting the connection close on completion in the workflow
properties ?

Also if you are using 2000 you can get rid of the insantiating the ADO
stuff.

How to loop through a global variable Rowset
(http://www.sqldts.com/Default.aspx?298)

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.allisonmitchell.com - Expert SQL Server Consultancy.
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


<bb_43 (AT) hotmail (DOT) com> wrote

Quote:
Using code examples from sqldts.com, I'm trying to use the same datapump
task
to import data from multiple source databases, ito a single db.
All of this occurs on the same server.

The code snippet below will loop thru once for each entry in the
companyinfo
table, and the connection object shows the correct database each time.
But the data always comes from the first database .
The msgbox shows the correct database, and the rpf increments correctly.

Any Ideas?





'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()
DIM connLocal
DIM rs1
dim strSQL
dim oPKG
dim oConnection

'instantiate DTS objects
Set oPKG =DTSGlobalVariables.Parent
set stpEnterLoop = opkg.Steps("DTSStep_DTSDataPumpTask_1")
set stpFinished = opkg.Steps("DTSStep_DTSActiveScriptTask_2")
stpEnterLoop.DisableStep=True

' instantiate the ADO objects
set connLocal = CreateObject("ADODB.Connection")
connLocal.ConnectionTimeout=45
connLocal.CommandTimeout=90
set rs1 = CreateObject("ADODB.Recordset")



'LoadSite
connLocal.Open = "Provider=SQLOLEDB.1;Data Source=MMSMainVS; Initial
Catalog=RMX10;Application Name='GetPICs';Integrated Security='SSPI'"
strSQL="Select top 1 companyid,companyname,DBName from companyinfo where
active= 1 and companyID<95 and companyID >"
strSQL=strSQL & DTSGlobalVariables("RPF").value
strSQL=strSQL & " order by companyid"
rs1.open strSQL,connLocal
IF not rs1.eof THEN
Set oConnection = oPKG.Connections("SiteData")
oConnection.Catalog = rs1.fields(2)

DTSGlobalVariables("RPF")=rs1.fields(0)
msgbox(oConnection.Catalog & " " &
DTSGlobalVariables("RPF").value)
stpFinished.DisableStep=TRUE
stpEnterLoop.DisableStep=FALSE
stpEnterLoop.ExecutionStatus=DTSStepExecStat_Waiti ng

END IF
IF rs1.EOF THEN
stpFinished.DisableStep=FALSE
stpEnterLoop.DisableStep=TRUE
stpFinished.ExecutionStatus=DTSStepExecStat_Waitin g
END IF
rs1.close
conn.close
Main=DTSTaskExecResult_Success


End Function



Reply With Quote
  #3  
Old   
bb_43@hotmail.com
 
Posts: n/a

Default Re: DTS Loop thru Multiple Datapump Sources - 01-10-2004 , 04:33 PM



In article <ubzA$E01DHA.2528 (AT) TK2MSFTNGP09 (DOT) phx.gbl>, "Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote:
Quote:
Are you setting the connection close on completion in the workflow
properties ?

Also if you are using 2000 you can get rid of the insantiating the ADO
stuff.


The problem doesn't seem to lie with the ADO connection and it's recordset in
the vbscript.
It invokes the data pump task for each record, and if I cancel in the middle,
the source DB is set to the correct one.
What SEEMS to be the problem is this:
Although the source connection is set to the proper db and the data pump task
shows the correct data if I hit "preview", the data from the first db is
retrieved each of the 11 loops.


Reply With Quote
  #4  
Old   
bb_43@hotmail.com
 
Posts: n/a

Default Re: DTS Loop thru Multiple Datapump Sources - 01-10-2004 , 04:37 PM



In article <ubzA$E01DHA.2528 (AT) TK2MSFTNGP09 (DOT) phx.gbl>, "Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote:
Quote:
Are you setting the connection close on completion in the workflow
properties ?

Also if you are using 2000 you can get rid of the insantiating the ADO
stuff.

How to loop through a global variable Rowset
(http://www.sqldts.com/Default.aspx?298)


Thanks!
I set the connection close workflow property and it works perfectly, now.




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.