Executing DTS Package

S

scott

I've been running below script to execute a SQL DTS job for several years
with no problem. Recently, I upgraded our server to Win 2003. After the
fresh install, and getting sql setup, etc. I recreated the dts package.

Since then, I can't run below script using mixed or trusted mode on any
other pc besides mine. I created the package as administrator of domain, so
permissions/ownership should be a problem. Is there any other way to execute
a dts package from access?


ERROR
**********************

Error: -2147467259

Source: ms ole db provider for sql server

Cannot open database requested in login

Login fails


CODE
**********************

Dim oPKG As DTS.Package, oStep As DTS.Step
Set oPKG = New DTS.Package

Dim sServer As String, sUsername As String, sPassword As String
Dim sPackageName As String, sMessage As String
Dim lErr As Long, sSource As String, sDesc As String

sServer = "myserver"
sUsername = "sa"
sPassword = "password"
sPackageName = "production_update"

' Use mixed mode authentication
'oPKG.LoadFromSQLServer sServer, sUsername, sPassword, _
' DTSSQLStgFlag_Default, , , , sPackageName

' Use Trusted Connection
oPKG.LoadFromSQLServer sServer, , , _
DTSSQLStgFlag_UseTrustedConnection, , , , sPackageName

' Set Exec on Main Thread
For Each oStep In oPKG.Steps
oStep.ExecuteInMainThread = True
Next

oPKG.Execute

' Get Status and Error Message
For Each oStep In oPKG.Steps
If oStep.ExecutionResult = DTSStepExecResult_Failure Then
oStep.GetExecutionErrorInfo lErr, sSource, sDesc
sMessage = sMessage & "Step """ & oStep.Name & _
""" Failed" & vbCrLf & _
vbTab & "Error: " & lErr & vbCrLf & _
vbTab & "Source: " & sSource & vbCrLf & _
vbTab & "Description: " & sDesc & vbCrLf & vbCrLf
Else
sMessage = sMessage & "Step """ & oStep.Name & _
""" Succeeded" & vbCrLf & vbCrLf
End If
Next

oPKG.UnInitialize

Set oStep = Nothing
Set oPKG = Nothing

MsgBox sMessage
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top