Re: DTS package Execute() failure in VB.Net -
06-08-2005
, 09:19 AM
Hi Jerry,
I had the same problems. After researching and pulling out the little
hair I have left I came up with this:
Stored Procedure:
CREATE procedure stp_ExecuteDTS
--@GlobalVar1 varchar(50),
--@GlobalVar2 varchar(50)
as
declare @jid uniqueidentifier
declare @id int
-- Specify DTS to be executed
declare @dts varchar(128)
set @dts = 'SYNCHALL'
-- Initialize command
declare @cmd varchar(4000)
set @cmd = '"C:\PROGRAM FILES\MICROSOFT SQL
SERVER\80\TOOLS\BINN\Dtsrun.exe" /S "(local)" /N "' + @dts + '" /W "0"
/E '
-- Specify global variables values to be passed to DTS trough DTSRUN
--set @cmd = @cmd + '/A GV1:8="' + @GlobalVar1 + '" '
--set @cmd = @cmd + '/A GV2:8="' + @GlobalVar2 + '" '
-- Create a unique job name
--
declare @jname varchar(128)
set @jname = cast(newid() as char(36)) -- Uncomment this to ALLOW TO
RUN MULTIPLE DTS INSTANCES AT THE SAME TIME
--set @jname = 'AspxDtsJob' -- Uncomment this to ALLOW TO RUN ONLY ONE
DTS INSTANCE AT TIME (default)
-- Create job
exec msdb.dbo.sp_add_job
@job_name = @jname,
@enabled = 1,
@category_name = 'ASPX',
@delete_level = 1,
@job_id = @jid OUTPUT
exec msdb.dbo.sp_add_jobserver
@job_id = @jid,
@server_name = '(local)'
exec msdb.dbo.sp_add_jobstep
@job_id = @jid,
--@job_name = 'Test',
@step_name = 'Execute DTS',
@subsystem = 'CMDEXEC',
@command = @cmd
-- Start job
exec msdb.dbo.sp_start_job
@job_id = @jid
GO
and on the .net page normal stuff but the detail:
cmd.CommandText = "stp_ExecuteDTS"
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandTimeout = 900000
cmd.ExecuteNonQuery()
cmd.Dispose()
conn.Close()
I hope this helps.
Catch ya on the flipside,
Tony |