Hi,
Ive done this before with some problems,
I didnt use the SQL generated VB code.
I called the DTS package on the server directly from VB.
I addeed a reference to the DTS object Library dtspkg.dll.
I then executed it by calling the function below.
I added a List View on the Form to display the results ( You can remove the code that does this)
Private Sub Form_Load()
lvDTS.View = lvwReport
lvDTS.ColumnHeaders.Add 1, "col1", "Step"
lvDTS.ColumnHeaders.Item(1).Width = 1000
lvDTS.ColumnHeaders.Add 2, "col2", "Step Name"
lvDTS.ColumnHeaders.Item(2).Width = 5620
lvDTS.ColumnHeaders.Add 3, "col3", "Step Result"
lvDTS.ColumnHeaders.Item(3).Width = 1200
End Sub
'Function Call
ExecutePackage sServerName, sServerPassword, "", sDTSPackageName
'Function
Public Sub ExecutePackage(sServer As String, sUsername As String, sPassword As String, sPackageName As String)
'<EhHeader>
Dim lErrNum As Long
Dim sErrDesc As String
On Error GoTo ErrorBlock:
'</EhHeader>
Dim oPKG As DTS.Package, oStep As DTS.Step
1000 Set oPKG = New DTS.Package
Dim sMessage As String
Dim lErr As Long, sSource As String, sDesc As String
Dim iListCount As Integer
Dim lsitem As Object
Dim sStepName As String
Dim sStepResult As String
' Load Package
1001 oPKG.LoadFromSQLServer sServer, sUsername, sPassword, _
iConnectionType, , , , sPackageName
1002 frmRunning.Refresh
' Set Exec on Main Thread
1003 For Each oStep In oPKG.Steps
1004 oStep.ExecuteInMainThread = True
Next
' Execute
1005 oPKG.Execute
' Get Status and Error Message
1006 For Each oStep In oPKG.Steps
1007 iListCount = iListCount + 1
1008 If oStep.ExecutionResult = DTSStepExecResult_Failure Then
1009 frmRunning.Label1.Caption = "Sending E-Mail"
1010 oStep.GetExecutionErrorInfo lErr, sSource, sDesc
1011 sMessage = sMessage & "Step """ & oStep.Name & _
""" Failed" & vbCrLf & _
vbTab & "Error: " & lErr & vbCrLf & _
vbTab & "Source: " & sSource & vbCrLf & _
vbTab & "Description: " & sDesc & vbCrLf & vbCrLf
1012 sStepResult = "Failed"
1013 sStepName = oStep.Name
1014 MsgBox sMessage, vbCritical, App.Title
1015 gLogEmail.Log sMessage, True
1016 sMessage = ""
Else
1018 sStepResult = "Succeeded"
1019 sStepName = oStep.Name
End If
1020 sMessage = RemoveUnwantedChars(sMessage)
1021 Set lsitem = frmMain.lvDTS.ListItems.Add(, "a" & iListCount, iListCount)
1022 lsitem.SubItems(1) = sStepName
1023 lsitem.SubItems(2) = sStepResult
Next
1024 oPKG.UnInitialize
1025 Set oStep = Nothing
1026 Set oPKG = Nothing
'<EhFooter>
Exit Sub
ErrorBlock:
lErrNum = Err.Number
sErrDesc = Err.Description
Dim sErrDetail As String
Dim lErrLine As Long
lErrLine = Erl
sErrDetail = "Error Description: [" & sErrDesc & "] - Error Number: " & lErrNum & " - " & " (RedHatWebOrders.mDTS.ExecutePackage) " & " Line " & CStr(lErrLine)
MsgBox sErrDetail, vbCritical, App.Title
'</EhFooter>
End Sub
This should work fine for you. You can customise it yourself.
One thing to note though, you have to have SQL Client Tools installed on the PC that runs this VB app. I found this after a lot of hassle, on Microsfts Tech Site.
Hope this helps.
Off home now.