>I am having dificulty resolving this build error:
>
>Interface 'DTS.Steps' cannot be indexed because it has no default property.
>
>This is from code directly from M$ and it does not work.
>
>
>Public Sub StepPrecedenceConstraint()
> 'Declare the step and precedence constraint.
> Dim objStep As DTS.Step
> Dim objConstraint As DTS.PrecedenceConstraint
>
> 'TransformData only runs when ClearTables completes.
>
>
> objStep = objPackage.Steps("TransformData") 'ERROR is with the Steps object
>
>
> objConstraint = objStep.PrecedenceConstraints.New("ClearTables")
> objConstraint.PrecedenceBasis = DTSStepPrecedenceBasis_ExecStatus
> objConstraint.Value = DTSStepExecStat_Completed
> objStep.PrecedenceConstraints.Add(objConstraint)
>
> 'GenerateDoc only runs when TransformData is successful.
> objStep = objPackage.Steps("GenerateDoc")
> objConstraint = objStep.PrecedenceConstraints.New("TransformData")
> objConstraint.PrecedenceBasis = DTSStepPrecedenceBasis_ExecResult
> objConstraint.Value = DTSStepExecResult_Success
> objStep.PrecedenceConstraints.Add(objConstraint)
>
> 'SendMail only runs when TransformData fails.
> objStep = objPackage.Steps("SendMail")
> objConstraint = objStep.PrecedenceConstraints.New("TransformData")
> objConstraint.PrecedenceBasis = DTSStepPrecedenceBasis_ExecResult
> objConstraint.Value = DTSStepExecResult_Failure
> objStep.PrecedenceConstraints.Add(objConstraint)
> End Sub
Is this code part of a CLR-function in SQL2005? The error message "Interface 'DTS.Steps' cannot be indexed because it has no default property." doesn't make sense because VB.NET would not have let you compile the code if DTS.Steps was an interface instead of a collection.
Anyways, you can try this instead:
objStep = objPackage.Steps.Item("TransformData")
If this works, that means in the DTS class you are missing the Default keyword in the Item property declarations.