Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,190 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,135 people online right now. Registration is fast and FREE... Join Now!




ueryInterface for interface DTS.CustomTask failed

 
Reply to this topicStart new topic

ueryInterface for interface DTS.CustomTask failed

Arijit.chaterjee
28 Aug, 2007 - 02:06 AM
Post #1

New D.I.C Head
*

Joined: 28 Aug, 2007
Posts: 1


My Contributions
I am Arijit,
trying to make an exe for Transfering a database objects to another databse writing the code as follwos.


Dim oPackage As New DTS.Package2
'Dim oConnetion As DTS.Connection2
Dim oStep As Step2
Dim oTask As Task
Dim oCustomTask As TransferObjectsTask2

Try
oStep = oPackage.Steps.[New]
oTask = oPackage.Tasks.[New]("DTSTransferObjectsTask")
oCustomTask = oTask.CustomTask
oPackage.FailOnError = False

With oStep

.Name = "Copy Database design and data"
.ExecuteInMainThread = True

End With

With oTask
.Name = "GenericPackageTask"
End With


With oCustomTask
.Name = "DTSTransferObjectsTask"
.SourceServer = "HOME-SERVER"
.SourceUseTrustedConnection = True
.SourceDatabase = "NORTHWIND"

.DestinationServer = "HOME-SERVER"
.DestinationUseTrustedConnection = True
.DestinationDatabase = "AC"

.CopyAllObjects = True
.IncludeDependencies = False
.IncludeLogins = False
.IncludeUsers = False

.DropDestinationObjectsFirst = True
.CopySchema = True
.CopyData = DTS.DTSTransfer_CopyDataOption.DTSTransfer_ReplaceData

End With

'oStep.TaskName = oCustomTask.Name
oStep.TaskName = oTask.Name
oPackage.Steps.Add(oStep)
oPackage.Tasks.Add(oTask)
oPackage.Execute()

oCustomTask = Nothing
oTask = Nothing
oStep = Nothing
oPackage.UnInitialize()

Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

But an error generating on the follwing line
oCustomTask = oTask.CustomTask
as QueryInterface for interface DTS.CustomTask failed.

Plz give me a solution for this.

User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: UeryInterface For Interface DTS.CustomTask Failed
28 Aug, 2007 - 04:12 AM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,983



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Im not going to even attempt to read that code until you put it in code blocks (the button with the # on it in the toolbar) smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 01:21AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month