Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
arunanand
Starting Member
2 Posts |
Posted - 2009-03-27 : 10:46:20
|
Hello Guys,I have created a DTS for importing multiple text files from a folder location and carry the Transformation to load the data onto the Table. Before the Transformation i am adding a Active X Script Task to Loop for all the Text Files. But I am stuck at a VB error (not great in debugging VB) it gives me an error "Invalid procedure call or argument". The code goes like this:' 246 (Begin Loop)Option ExplicitFunction Main()Dim pkgDim conTextFile Dim stpEnterLoopDim stpFinishedset pkg = DTSGlobalVariables.Parentset stpEnterLoop = pkg.Steps("DTSStep_DTSDataPumpTask_1")set stpFinished = pkg.Steps("DTSStep_DTSActiveScriptTask_5")set conTextFile = pkg.Connections("Text File (Source)")' We want to continue with the loop only if there is' one or more text file in the directory. If the function ShouldILoop' returns true then we disable the step that takes us out of the package' and continue processingif ShouldILoop = True thenstpEnterLoop.DisableStep = FalsestpFinished.DisableStep = TrueconTextFile.DataSource = DTSGlobalVariables("\a-13\BGSMapps\LIVE\CLO\Databases\TEMP\RedirectionReportsRawData\AwayReports\tmpFileImport\EDF\ReDirect1.txt").ValuestpEnterLoop.ExecutionStatus = DTSStepExecStat_WaitingelsestpEnterLoop.DisableStep =TruestpFinished.DisableStep = FalsestpFinished.ExecutionStatus = DTSStepExecStat_WaitingEnd ifMain = DTSTaskExecResult_SuccessEnd FunctionFunction ShouldILoopDim fsoDim fil Dim fold Dim pkgDim counterDim GetFolderset pkg = DTSGlobalVariables.Parentset fso = CREATEOBJECT("Scripting.FileSystemObject")'This is where the error is appearingset fold = fso.GetFolder(DTSGlobalVariables("\a-13\BGSMapps\LIVE\CLO\Databases\TEMP\RedirectionReportsRawData\AwayReports\tmpFileImport\EDF\Redirect1.txt").Value)counter = fold.files.count' So long as there are text files in the directory carry onif counter >= 1 thenfor each fil in fold.FilesDTSGlobalVariables("\a-13\BGSMapps\LIVE\CLO\Databases\TEMP\RedirectionReportsRawData\AwayReports\tmpFileImport\EDF\ReDirect1.txt").Value = fil.pathShouldILoop = CBool(True)NextelseShouldILoop = CBool(False)End ifEnd Function |
|
|
|
|