|
-
Sep 27th, 2001, 02:39 PM
#1
Thread Starter
Junior Member
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.
-
Sep 27th, 2001, 03:13 PM
#2
Lively Member
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
-
Sep 27th, 2001, 03:16 PM
#3
Lively Member
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 !
-
Sep 27th, 2001, 04:45 PM
#4
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|