Hello All,
I have a VB task on the DTS which uploads the CSV files to the SQL tables. If there are no CSV files I want the VB task to write a errorlog row in the sql table.
Can anyone tell me how to add the logic to insert row in SQL table from VB script task?
Here is the check on the csv file in VB script task:
Set fso=CreateObject("Scripting.FileSystemObject")
Set fsoFolder = fso.GetFolder(sFolder)
if fsoFolder.files.count <> 0 then
For Each fsoFile in fsoFolder.Files
'Get first filenme
IF lcase(Right(fsoFile.name, Len(fsoFile.name) - InStrRev(fsoFile.name, ".")) ) <> Lcase(sFileExtension) OR Lcase(Left(fsoFile.name, 6)) <> Lcase(sFilePrefix) Then
'Insert the row ('No CSV files') in the SQL ErrorLog table and exit out of DTS
ELSE
sFileName = sFolder & fsoFile.Name
sFile = fsoFile.Name
Exit For
END IF
Next
else
'Insert the row ('No CSV files') in the SQL ErrorLog table and exit out of DTS
Main = DTSTaskExecResult_failure
End if
Thanks,
-techiPA
I have a VB task on the DTS which uploads the CSV files to the SQL tables. If there are no CSV files I want the VB task to write a errorlog row in the sql table.
Can anyone tell me how to add the logic to insert row in SQL table from VB script task?
Here is the check on the csv file in VB script task:
Set fso=CreateObject("Scripting.FileSystemObject")
Set fsoFolder = fso.GetFolder(sFolder)
if fsoFolder.files.count <> 0 then
For Each fsoFile in fsoFolder.Files
'Get first filenme
IF lcase(Right(fsoFile.name, Len(fsoFile.name) - InStrRev(fsoFile.name, ".")) ) <> Lcase(sFileExtension) OR Lcase(Left(fsoFile.name, 6)) <> Lcase(sFilePrefix) Then
'Insert the row ('No CSV files') in the SQL ErrorLog table and exit out of DTS
ELSE
sFileName = sFolder & fsoFile.Name
sFile = fsoFile.Name
Exit For
END IF
Next
else
'Insert the row ('No CSV files') in the SQL ErrorLog table and exit out of DTS
Main = DTSTaskExecResult_failure
End if
Thanks,
-techiPA