Tuesday, February 14, 2012

DTS Help

Hey guys,
In my DTS package I have an ActiveX Script that basicaly checkes if records exist in a table something like this:
Const adOpenKeyset = 1
Const adLockOptimistic = 3

Function FindRec()

Dim objConn
Dim sql
Dim rs

Dim Success

Success = 0

sqlconn = "DSN=SAConn;UID=PSI_Admin;PWD=psiadmin001;DATABASE= SA"

Set objConn = CreateObject("ADODB.Connection")
objConn.Open sqlconn

sql = "SELECT NAM FROM tblUnassignedNAM "

Set rs = CreateObject("ADODB.RecordSet")
rs.Open sql, objConn, adOpenKeyset, adLockOptimistic

If rs.EOF = False Then

Success = 1

End If

rs.Close
Set rs = Nothing

objConn.Close
Set objConn = Nothing

If Success = 1 Then
FindRec = DTSStepExecResult_Success
ElseIf Success = 0 Then
FindRec = DTSStepExecResult_Failure
End If

End Function

If you notice at the end I say
If Success = 1 Then
FindRec = DTSStepExecResult_Success
ElseIf Success = 0 Then
FindRec = DTSStepExecResult_Failure
End If

So if there are no records it should fail and do something else, but the process does not fail it's successful. Why is that?You are simply returning the numeric value of the errors. You are not throwing an error.

No comments:

Post a Comment