Results 1 to 4 of 4

Thread: DTS question

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2001
    Posts
    19

    Angry DTS question

    Thank you for taking time in looking into this.
    I am new at VB so please give as much explanation as you can.
    I need to create DTS package to import an .xls file into a table in MS sql and be able to execute this package in VB at a click of a command button.. any help will be appriciated. What is the best way to achive this.


    -Shilpa
    Last edited by Shilpa; Sep 27th, 2001 at 02:44 PM.

  2. #2
    Lively Member
    Join Date
    Jan 2001
    Posts
    72
    Here's a lil snippet from one of my programs.

    I actually got it from some website, I think it's www.swynk.com .



    Code:
    Dim oPKG As DTS.Package, oStep As DTS.Step, oTask As DTS.Task
    Set oPKG = New DTS.Package
    
    oPKG.LoadFromSQLServer servername, username, password, _
            DTSSQLStgFlag_Default, , , , nameofDTS
                
    ' Set Exec on Main Thread
    For Each oStep In oPKG.Steps
                oStep.ExecuteInMainThread = True
    Next
            
     ' Execute
    oPKG.Execute
    
    For Each oStep In oPKG.Steps
           If oStep.ExecutionResult = DTSStepExecResult_Failure Then
                    oStep.GetExecutionErrorInfo lErr, sSource, sDesc
                    sMessage = sMessage & "Step """ & oStep.Name & _
                        """ Failed" & vbCrLf & _
                        vbTab & "Error: " & lErr & vbCrLf & _
                        vbTab & "Source: " & sSource & vbCrLf & _
                        vbTab & "Description: " & sDesc & vbCrLf & vbCrLf
           Else
                    sMessage = sMessage & "Step """ & oStep.Name & _
                        """ Succeeded" & vbCrLf & vbCrLf
           End If
     Next
            
    oPKG.UnInitialize
            
    Set oStep = Nothing
    Set oPKG = Nothing

  3. #3
    Lively Member
    Join Date
    Jan 2001
    Posts
    72

    Sorry

    The above example will run the package from VB. As for creating the DTS, well, it shouldn't be too hard. If you have trouble, just look online for examples or get a good book. Good Luck !

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 2001
    Posts
    19

    Smile

    Thank You ttlai
    I will give it a try.

Posting Permissions

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



Click Here to Expand Forum to Full Width