Hi ,
i am using VS.NET 2003 for programming and SQL sever 2005 is my database.
while creating DTS packages,
i am using code as follows
Public Sub Task_Sub4(ByVal goPackage As Object)
Dim oTask As DTS.Task
Dim oLookup As DTS.Lookup
Dim oCustomTask4 As DTS.DataPumpTask2
oTask = CType(goPackage, DTS.Package).Tasks.New("DTSExecuteSQLTask")
oCustomTask4 = CType(oTask.CustomTask, DTS.DataPumpTask2)
oCustomTask4.Name = "Copy Data from contact_info to [content_shriya].[dbo].contact_info] Task"
oCustomTask4.Description = "Copy Data from contact_info to [content_shriya].[dbo].[contact_info] Task"
oCustomTask4.SourceConnectionID = 3
oCustomTask4.SourceSQLStatement = "select * from [Content_management].[dbo].[contact_info]"
oCustomTask4.DestinationConnectionID = 4
oCustomTask4.DestinationObjectName = "[content_shriya].[dbo].[contact_info]"
oCustomTask4.ProgressRowCount = 1000
oCustomTask4.MaximumErrorCount = 0
oCustomTask4.FetchBufferSize = 1
oCustomTask4.UseFastLoad = True
oCustomTask4.InsertCommitSize = 0
oCustomTask4.ExceptionFileColumnDelimiter = "|"
oCustomTask4.ExceptionFileRowDelimiter = vbCrLf
oCustomTask4.AllowIdentityInserts = False
oCustomTask4.FirstRow = 0
oCustomTask4.LastRow = 0
oCustomTask4.FastLoadOptions = 2
oCustomTask4.ExceptionFileOptions = 1
oCustomTask4.DataPumpOptions = 0
'Call oCustomTask4_Trans_Sub1(oCustomTask4)
goPackage.Tasks.Add(oTask)
oCustomTask4 = Nothing
oTask = Nothing
End Sub
But i am geeting error in line
oCustomTask4 = CType(oTask.CustomTask, DTS.DataPumpTask2)
giving error 'System.InvalidCastException'
Additional information: Specified cast is not valid.
i changed it with oCustomTask4 = oTask.CustomTask ,
then also similar error appear.
Please solve my problem, i need to create DTS Packages by using VS.NET 2003 and Database is SQL server 2005.
Thank you
You might have better success posting this in the DTS forum.
I'm not an expert in DTS programming, but since you created oTask as an ExecuteSQLTask, I don't think you can cast it to a DataPumpTask. You need to create it as a DataPumpTask.
|||
Thank you Jhon the code works.
|||Mark the response that was helpful as an answer, please. It helps with searching in the forum.
No comments:
Post a Comment