Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2005
    Posts
    4

    Unanswered: Visual Basic executes DTS Package

    I have created a rule in outlook to run this Visual Basic Script when I receive a specific email. The codes runs a SQL Server DTS Package that imports data and runs a couple of stored procs. If the DTS package takes a while to execute my outlook will lock up until the entire package is complete. I want to run the DTS package to run but I don’t want the application to remain locked till its complete. Anyone have any ideas of how to get around this....


    Public Sub RunTVDTSPackage(Item As Outlook.MailItem)
    Dim oPackage As New DTS.Package
    On Error GoTo eh

    oPackage.LoadFromSQLServer "DummyServerName", "DummyUser", "DummyPSWd", _
    DTSSQLStgFlag_Default, _
    "", "", "", "Top_Customer - TV", 0
    'Execute the Package

    oPackage.Execute
    'MsgBox oPackage.Description, vbInformation, _
    "Re-import Excel sheet."

    'Clean up.
    MsgBox ("Ran DTS Package")
    Set oPackage = Nothing
    Exit Sub
    eh:
    MsgBox Err.Description, vbCritical, _
    "Error Running Package"

    End Sub

  2. #2
    Join Date
    Dec 2004
    Location
    CA, USA
    Posts
    63
    Here's how I do it with VBScript:


    Set WshShell = WScript.CreateObject("WScript.Shell")
    strDTSRun_Command = "dtsrun.exe /Syoursqlserver /Ulogin /Ppassword /Nnameofdtspackage"

    iWindowStyle = 10
    bWaitOnReturn = false
    WshShell.Run(strDTSRun_Command, iWindowStyle, bWaitOnReturn)

  3. #3
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    perhaps you can take some metrics about cpu usage when the job succeeds or fails and perhaps use sp_monitor to check these conditions when you run the job. Is the SQL server on another computer?
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  4. #4
    Join Date
    Jan 2005
    Posts
    4
    pshisbey
    Do I need to reference s certain library to use

    Set WshShell = WScript.CreateObject("WScript.Shell")
    strDTSRun_Command = "dtsrun.exe /Syoursqlserver /Ulogin /Ppassword /Nnameofdtspackage"

    iWindowStyle = 10
    bWaitOnReturn = false
    WshShell.Run(strDTSRun_Command, iWindowStyle, bWaitOnReturn)

    When i try to compile the code sais WSRIPT is not defined.....


    Carlos

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •