Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Change DTS Package?

Author  Topic 

brendalisalowe
Constraint Violating Yak Guru

269 Posts

Posted - 2004-10-20 : 12:01:23
I am trying to change a DTS package during runtime, but I have no idea why. Can anyone see why this won't work?

'change DTS Package
Dim oPKG As DTS.Package, oStep As DTS.Step
oPKG = New DTS.Package
Dim oConn As DTS.Connection

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

' Set Parameter Values
sServer = "CRSERVER"
sUsername = "brenda"
sPassword = "g_Password"
sPackageName = "other3"

' Load Package
oPKG.LoadFromSQLServer(sServer, sUsername, sPassword, _
DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection, , , , sPackageName)

'Set Filename
Dim ofd As New OpenFileDialog
With ofd
.Title = "Choose An Excel File"
.InitialDirectory = "C:\Accurint\"
.Filter = "XLS (*.xls)|*.xls|All files (*.*)|*.*"
.FilterIndex = 2
.RestoreDirectory = True
.Multiselect = False
End With
ofd.ShowDialog()
oPKG.Connections.Item("Connection 1").DataSource = ofd.FileName
oConn = Nothing

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


' Execute
oPKG.Execute()

' Get Status and Error Message
For Each oStep In oPKG.Steps
If oStep.ExecutionResult = DTS.DTSStepExecResult.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()

oStep = Nothing
oPKG = Nothing

' Display Results
MsgBox(sMessage)


Is my package setup wrong maybe? Do I need to use Active Script? How? Any ideas? I have been stressing about this for days and I can't find any answers. HELP!

Brenda

If it weren't for you guys, where would I be?

nr
SQLTeam MVY

12543 Posts

Posted - 2004-10-21 : 04:44:09
What happens when you run it?
I do this sort of thing by setting a global variable in the package then using an activex script to set it.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -