dbTalk Databases Forums  

How execute DTS from a ASP

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


Discuss How execute DTS from a ASP in the microsoft.public.sqlserver.dts forum.



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

Default How execute DTS from a ASP - 02-21-2006 , 05:09 PM






Hello,
I have found the script that allow to execute the DTS from asp but I have a
qeston

It is possible to execute the script from a ASP page that is on a IIS on a
different server of SQL server?

If yes How?


folowing is the ASP script that I have found

<%@Language=VBScript %>
<% ' 207
Option Explicit
Response.Buffer = False
%>

<%
Const DTSSQLStgFlag_Default = 0
Const DTSStepExecResult_Failure = 1

Dim oPkg, oStep, sErr, bSuccess

Dim sServer, iSecurity, sUID, sPWD, sPkgName, sPkgPWD

' Get Form Variables
sServer = Request.Form("txtServer")
iSecurity = CInt("0" & Request.Form("optSecurity"))
sUID = Request.Form("txtUID")
sPWD = Request.Form("txtPWD")
sPkgName = Request.Form("txtPkgName")
sPkgPWD = Request.Form("txtPkgPWD")

' Validate Variables
If Len(sServer) = 0 Then sErr = "<li>Invalid Server Name"
If iSecurity = 0 And Len(sUID) = 0 Then _
sErr = sErr & "<li>Invalid Username for SQL Security"
If Len(sPkgName) = 0 Then sErr = sErr & "<li>Invalid Package Name"


If Len(sErr) = 0 Then
Response.Write "<p>Executing " & sPkgName & " from " & _
sServer & "</p>"

' Load the Package Set
oPkg = Server.CreateObject("DTS.Package")
oPkg.LoadFromSQLServer sServer, sUID, sPWD, iSecurity , sPkgPWD, "", "",
sPkgName

' Execute the Package
oPkg.Execute

bSuccess = True

' Report Step status
For Each oStep In oPkg.Steps
sErr = sErr & "<p> Step [" & oStep.Name & "] "
If oStep.ExecutionResult = DTSStepExecResult_Failure Then
sErr = sErr & " failed<br>"
bSuccess = False
Else
sErr = sErr & " succeeded<br>"
End If
sErr = sErr & "Task """ & _
oPkg.Tasks(oStep.TaskName).Description & """</p>"
Next

If bSuccess Then
sErr = sErr & "<p>Package [" & oPkg.Name & "] succeeded</p>"
Else
sErr = sErr & "<p>Package [" & oPkg.Name & "] failed</p>"
End If
End If

' Clean Up
oPkg.UnInitialize
Set oStep = Nothing
Set oPkg = Nothing

Response.Write sErr
Response.Write "<p>Done</p>"

%>




thank you
Milani Omar



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.