Modifying the SQLStatement property

  • I am trying to setup an ActiveX task that asks the user for a table name and then sets the SQLStatement of an ExecuteSQLTask2 task. THe basic idea is to ask for the name of a table and then delete all records from that table.

    The problem is that when I run this, I get a VBScript error that the "Object doesn't support this property or method".

    Here is the script.

    Function Main()

    Dim TableName

    Dim oPKG

    Dim oTSK

    Set oPKG = DTSGlobalVariables.Parent

    Set oTSK = oPKG.Tasks("DTSTask_DTSExecuteSQLTask_2")

    TableName = UCase(inputbox("Enter the name of the table that will be processed."))

    if len(TableName)=0 then

    Main = DTSTaskExecResult_Failure

    else

    msgbox(otsk.SQLStatement)

    oTSK.SQLStatement = "DELETE FROM " & TableName

    Main = DTSTaskExecResult_Success

    end if

    End Function

    Does anyone have any idea why I keep getting this error? The target task IS an ExecuteSQLTask2 and the name IS spelled correctly.

    Any help would be appreciated. Thanks.

  • Use this instead:

     

    Set oTSK = oPKG.Tasks("DTSTask_DTSExecuteSQLTask_2").CustomTask

  • Thank you Erik. That did the trick.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply