-
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
-
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
-
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 ! :D
-
Thank You ttlai
I will give it a try.