|
Thread: Dts
-
Jul 20th, 2003, 06:27 PM
#1
Thread Starter
Fanatic Member
Dts
Trying to use DTS in vb.net
Have reference to the following:
Dtspkg.dll—Microsoft DTSPackage Object Library
Dtspump.dll—Microsoft DTSDataPump Scripting Object Library
Custtask.dll—Microsoft DTS Custom Tasks Object Library
But there is an error on the line which is "oCustomTask = oTask.CustomTask" see below...
The error message is : error 13: QueryInterface for interface DTS.Custom.Task failed
I am running sql server 7.0 and I wonder if I should be using sql server 2000 to resolve this error message.
If this is the case then how can the code be used in sql server 7.0?
Thanks
Here is the code that is being used...
Private Sub frmDTS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DTS()
End Sub
Private Sub DTS()
Dim oPackage As New DTS.Package2
Dim oConnection As DTS.Connection
Dim oStep As DTS.step2
Dim oTask As DTS.Task
Dim oCustomTask As DTS.BulkInsertTask
Try
oConnection = oPackage.Connections.New("SQLOLEDB")
oStep = oPackage.Steps.New
oTask = oPackage.Tasks.New("DTSBulkInsertTask")
oCustomTask = oTask.CustomTask
With oConnection
oConnection.Catalog = "pubs"
oConnection.DataSource = "(local)"
oConnection.ID = 1
oConnection.UseTrustedConnection = True
oConnection.UserID = "userid"
oConnection.Password = "password"
End With
oPackage.Connections.Add(oConnection)
oConnection = Nothing
With oStep
.Name = "GenericPkgStep"
.ExecuteInMainThread = True
End With
With oCustomTask
.Name = "GenericPkgTask"
.DataFile = "c:\dts\authors.txt"
.ConnectionID = 1
.DestinationTableName = "pubs..authors"
.FieldTerminator = "|"
.RowTerminator = "\r\n"
End With
oStep.TaskName = oCustomTask.Name
With oPackage
.Steps.Add(oStep)
.Tasks.Add(oTask)
.FailOnError = True
End With
oPackage.Execute()
Catch ex As Exception
MsgBox("Error: " & CStr(Err.Number) & vbCrLf & _
Err.Description, vbExclamation, oPackage.Name)
Finally
oConnection = Nothing
oCustomTask = Nothing
oTask = Nothing
oStep = Nothing
If Not (oPackage Is Nothing) Then
oPackage.UnInitialize()
End If
End Try
End Sub
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
|