Thursday, November 03, 2005

Code sample: How to run a Sql Server DTS Job from VB .Net


Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ExecuteDTS("sqlserver", "nameofDTSJob", , )

End Sub
'Reference Microsoft DTSPackage Object Library
Public Sub ExecuteDTS(ByVal sServer As String, ByVal sPackage As String, _
Optional ByVal sUser As String = vbNullString, _
Optional ByVal sPassword As String = vbNullString)

Dim oPackage As DTS.Package2 'The DTS Package Object

' Initialize DTS Package
oPackage = New DTS.Package2

' Run DTS Package
' LoadFromSQLServer can be replaced with LoadFromRepository or
' LoadFromStorageFile depending on the storage location of the package
oPackage.LoadFromSQLServer(sServer, sUser, sPassword, _
DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection, , , , sPackage)
oPackage.Execute()

' Cleanup
oPackage = Nothing
End Sub

End Class

1 comment:

  1. Anonymous3:00 PM

    Howdy,

    I keep coming to this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]Lots of good information here wintechpost.blogspot.com. Let me tell you one thing guys, some time we really forget to pay attention towards our health. Are you really serious about your weight?. Research shows that about 50% of all U.S. adults are either obese or weighty[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] Hence if you're one of these people, you're not alone. Infact many among us need to lose 10 to 20 lbs once in a while to get sexy and perfect six pack abs. Now the question is how you are planning to have quick weight loss? [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss[/url] is not like piece of cake. You need to improve some of you daily habbits to achive weight loss in short span of time.

    About me: I am blogger of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also mentor who can help you lose weight quickly. If you do not want to go under painful training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for effective weight loss.

    ReplyDelete