Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTS packages in VB.NET

Status
Not open for further replies.

vicvys

MIS
Feb 6, 2003
4
US
Hi.
I am new to VB.NET. I need to manipulate DTS packages from VB.NET application, I know how to do it in VB6, but have no idea how to do it in VB.NET. Can anyone help me with that ? What objects do I use ?

Thank you.
Victor.
 
Hey, Victor!

Maybe by helping you, you can help me. I've created a WebService in VB.Net that is to execute a DTS package. Problem is, I keep getting a COMException.

Here's the code. Maybe you (or some other brilliant mind) can help us both?

Code:
Imports System.Web.Services
Imports System.Data
Imports System.Data.SqlClient
Imports System.Runtime.InteropServices
Imports DTS

<System.Web.Services.WebService(Namespace:="[URL unfurl="true"]http://tempuri.org/ReportingWebService/RWS")>[/URL] _
Public Class RWS
    Inherits System.Web.Services.WebService

    <WebMethod()> Public Function ForceDTSsynch(ByVal TestMe As String)
        '//Created:     05/03/2004 by C. Michael Wells
        '//Purpose:     force DTS package synchronization
        '//Arguments:   NONE
        '//REFERENCES:  Microsoft DTSPackage Object Library (COM)
        '//             located at:  C:\Program Files\Microsoft SQL Server\80\Tools\Binn\dtspkg.dll
        '//Returns:     integer value, translated as follows:
        '//             1:  Job Completed Successfully
        '//             2:  COM error
        '//             3:  Other error

        '//declare variables:
        Dim pkg As New DTS.Package

        Try
            pkg.LoadFromSQLServer("servername", "userid", "password", _
                DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, _
                Nothing, Nothing, Nothing, "myPackage", Nothing)
            pkg.Execute()
            pkg.UnInitialize()
            pkg = Nothing
            Return 1    '//success 
        Catch exc As System.Runtime.InteropServices.COMException
            Return exc.ToString    '//COM error
        Catch exc As Exception
            Return 3    '//unspecified error
        End Try
    End Function
End Class

Here's the resulting exception:
Code:
  <?xml version="1.0" encoding="utf-8" ?> 
  <anyType xmlns:q1="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL] d1p1:type="q1:string" xmlns:d1p1="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xmlns="[URL unfurl="true"]http://tempuri.org/ReportingWebService/RWS">System.Runtime.InteropServices.COMException[/URL] (0x80040428): Package failed because Step 'Copy SQL Server Objects' failed. at DTS.PackageClass.Execute() at ReportingWebService.RWS.ForceDTSsynch(String TestMe) in C:\Inetpub\[URL unfurl="true"]wwwroot\ReportingWebService\RWS.asmx.vb:line[/URL] 118</anyType>

< M!ke >
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top