Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Pro VB.NET 2002/2003 For advanced Visual Basic coders working .NET version 2002/2003. Beginning-level questions will be redirected to other forums, including Beginning VB.NET.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 19th, 2007, 12:35 AM
Registered User
 
Join Date: Jun 2007
Location: Bangalore, Karnataka, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hari_vjti
Default DTS package error Plz Help

Hi Iam facing a problem with DTS package. and i was trying to execute the code which u gave in this site

type casting error is coming at this line

 oCustomTask = oTask.CustomTask

full code is below

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 = "Tony Patton"
                oConnection.Password = "Builder"
            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


PLZ help me out of this, iam struggling a lot with this error....plz give me suggestion

Regards

hari


Hari
Sr Sw Engg
SAP India-Bangalore


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with DTS PACKAGE mxwebb SQL Server DTS 1 November 28th, 2007 05:16 PM
DTS Package - Default database error interlogics SQL Server DTS 0 December 9th, 2005 06:30 AM
DTS Package Deployment acdsky VB Databases Basics 1 February 22nd, 2004 12:25 PM
DTS package Invalid Class error digriz60 SQL Server DTS 1 November 11th, 2003 01:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.