![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 |
#3
| |||
| |||
|
|
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. |
#4
| |||
| |||
|
|
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) |
![]() |
| Thread Tools | |
| Display Modes | |
| |