Friday, February 17, 2012

Execute DTS Package using a Stored Procedure from Button Push

I have a site that will run a DTS package from a stored procedure when a user pushes a button. I know the stored procedure works and exectures. I need the .net code on how to execute this particular type of SQL statement.

Any help would be AWESOME.

THX

This is the stored procedure stored in EM:

CREATE PROCEDURE spExportData

AS

Begin Transaction
Set nocount on
EXEC master..xp_cmdshell 'dtsrun /Ssql-06-db\a /NAdultExport -E'
Commit
GO

The code below is what I am currently using and is not working.

Protected Sub btnUpdateList_Clicked(Sender As Object, E As System.EventArgs)
Dim strProc As String = "spExportData"
Dim MyConnClass as New SQLConns
Dim sqlConn as SqlConnection
Dim myCommand As New SqlCommand

sqlConn = MyConnClass.OpenConn("ConnAdultEd")
MyCommand.CommandType = CommandType.StoredProcedure
MyCommand.CommandText = strProc
MyCommand.Connection = sqlConn
MyCommand.ExecuteNonQuery()
MyConnClass.CloseConn(sqlConn)

statuslbl.text = "File updated"

End Sub

stcyrje:

The code below is what I am currently using and is not working

Did you get any error message when calling the stored procedure to run the DTS package? You can also try Package class, take a look at:

http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.package(d=ide).aspx

No comments:

Post a Comment