dbTalk Databases Forums  

Call DTS Package from vb.net

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Call DTS Package from vb.net in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
adam
 
Posts: n/a

Default Call DTS Package from vb.net - 11-08-2004 , 10:09 AM






I am trying to call a DTS package from a VB.Net application. If my
application is on the DB server it works correctly. If I move the
application to another server the DTS packge is not run and no errors
are reported. Any ideas ?


pkg = New DTS.Package

'Begin - set up events sink
Dim cpContainer As UCOMIConnectionPointContainer
cpContainer = CType(pkg, UCOMIConnectionPointContainer)
Dim cpPoint As UCOMIConnectionPoint
Dim PES As PackageEventsSink = New PackageEventsSink

Output.Text = "<Start>" + vbCrLf

Dim guid As Guid = _
New Guid("10020605-EB1C-11CF-AE6E-00AA004A34D5")

cpContainer.FindConnectionPoint(guid, cpPoint)
Dim intCookie As Integer
cpPoint.Advise(PES, intCookie)

'pkg.LoadFromSQLServer("<server>", "<user>", "<password>",
_
' DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, _
' "", "", "", "<package name>", Nothing)
'".", "sa", ""
pkg.LoadFromSQLServer("192.168.100.100", "sa","", _
DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, _
"", "{A9CC66EC-E458-4284-BE79-1D49D2187514}", "",
"AKPAckageTest", Nothing)
'DTSSQLServerStorageFlags.DTSSQLStgFlag_Default

''MessageBox.Show("Execute")
pkg.Execute()

''MessageBox.Show("Finished")

pkg.UnInitialize()
pkg = Nothing
cpPoint.Unadvise(intCookie)
cpPoint = Nothing
cpContainer = Nothing
PES = Nothing
Catch exc As System.Runtime.InteropServices.COMException
''Output.Text = Output.Text + exc.Message + vbCrLf
MessageBox.Show(exc.Message)
errorFound = 1
Catch exc As Exception
''Output.Text = Output.Text + exc.Message + vbCrLf
MessageBox.Show(exc.Message)
errorFound = 1
Finally
Output.Text = Output.Text + "<Finish>" +
Date.Now().ToString + vbCrLf
End Try

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Call DTS Package from vb.net - 11-08-2004 , 11:00 AM






Your code reminds me of this KB -

HOW TO: Use DTS Package Events in Visual Basic .NET
(http://support.microsoft.com/default...b;en-us;321525)


....and if done correctly any errors in the package execution should be
captured by the OnError event. The Try Catch in the Sub Main will only catch
errors loading the package not those that arise during execution.

DTS is client side, the change in location and security context may well
effect the package execution.


--
Darren Green
http://www.sqldts.com

"adam" <adam (AT) thekrumholzs (DOT) com> wrote

Quote:
I am trying to call a DTS package from a VB.Net application. If my
application is on the DB server it works correctly. If I move the
application to another server the DTS packge is not run and no errors
are reported. Any ideas ?


pkg = New DTS.Package

'Begin - set up events sink
Dim cpContainer As UCOMIConnectionPointContainer
cpContainer = CType(pkg, UCOMIConnectionPointContainer)
Dim cpPoint As UCOMIConnectionPoint
Dim PES As PackageEventsSink = New PackageEventsSink

Output.Text = "<Start>" + vbCrLf

Dim guid As Guid = _
New Guid("10020605-EB1C-11CF-AE6E-00AA004A34D5")

cpContainer.FindConnectionPoint(guid, cpPoint)
Dim intCookie As Integer
cpPoint.Advise(PES, intCookie)

'pkg.LoadFromSQLServer("<server>", "<user>", "<password>",
_
' DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, _
' "", "", "", "<package name>", Nothing)
'".", "sa", ""
pkg.LoadFromSQLServer("192.168.100.100", "sa","", _
DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, _
"", "{A9CC66EC-E458-4284-BE79-1D49D2187514}", "",
"AKPAckageTest", Nothing)
'DTSSQLServerStorageFlags.DTSSQLStgFlag_Default

''MessageBox.Show("Execute")
pkg.Execute()

''MessageBox.Show("Finished")

pkg.UnInitialize()
pkg = Nothing
cpPoint.Unadvise(intCookie)
cpPoint = Nothing
cpContainer = Nothing
PES = Nothing
Catch exc As System.Runtime.InteropServices.COMException
''Output.Text = Output.Text + exc.Message + vbCrLf
MessageBox.Show(exc.Message)
errorFound = 1
Catch exc As Exception
''Output.Text = Output.Text + exc.Message + vbCrLf
MessageBox.Show(exc.Message)
errorFound = 1
Finally
Output.Text = Output.Text + "<Finish>" +
Date.Now().ToString + vbCrLf
End Try



Reply With Quote
  #3  
Old   
JFB
 
Posts: n/a

Default Re: Call DTS Package from vb.net - 11-08-2004 , 11:04 AM



Hi,
Make sure you are using UNC path not map drivers in you package.
JFB

"adam" <adam (AT) thekrumholzs (DOT) com> wrote

Quote:
I am trying to call a DTS package from a VB.Net application. If my
application is on the DB server it works correctly. If I move the
application to another server the DTS packge is not run and no errors
are reported. Any ideas ?


pkg = New DTS.Package

'Begin - set up events sink
Dim cpContainer As UCOMIConnectionPointContainer
cpContainer = CType(pkg, UCOMIConnectionPointContainer)
Dim cpPoint As UCOMIConnectionPoint
Dim PES As PackageEventsSink = New PackageEventsSink

Output.Text = "<Start>" + vbCrLf

Dim guid As Guid = _
New Guid("10020605-EB1C-11CF-AE6E-00AA004A34D5")

cpContainer.FindConnectionPoint(guid, cpPoint)
Dim intCookie As Integer
cpPoint.Advise(PES, intCookie)

'pkg.LoadFromSQLServer("<server>", "<user>", "<password>",
_
' DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, _
' "", "", "", "<package name>", Nothing)
'".", "sa", ""
pkg.LoadFromSQLServer("192.168.100.100", "sa","", _
DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, _
"", "{A9CC66EC-E458-4284-BE79-1D49D2187514}", "",
"AKPAckageTest", Nothing)
'DTSSQLServerStorageFlags.DTSSQLStgFlag_Default

''MessageBox.Show("Execute")
pkg.Execute()

''MessageBox.Show("Finished")

pkg.UnInitialize()
pkg = Nothing
cpPoint.Unadvise(intCookie)
cpPoint = Nothing
cpContainer = Nothing
PES = Nothing
Catch exc As System.Runtime.InteropServices.COMException
''Output.Text = Output.Text + exc.Message + vbCrLf
MessageBox.Show(exc.Message)
errorFound = 1
Catch exc As Exception
''Output.Text = Output.Text + exc.Message + vbCrLf
MessageBox.Show(exc.Message)
errorFound = 1
Finally
Output.Text = Output.Text + "<Finish>" +
Date.Now().ToString + vbCrLf
End Try



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.