SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On



Change Path of Files (.mdb, .xls, .txt) Expand / Collapse
Author
Message
Posted Wednesday, April 15, 2009 9:10 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, May 20, 2009 2:42 AM
Points: 2, Visits: 53
Hi, (sorry for my english, I'm from Switzerland)

I need to change the DataSource of several files in several Packages (Child) from another Package.

I can read the Datasource, but can't overrite/save it.
It doesn't notice an Error, but there's still the old Path.

Any Help?
T

Function Main()

Main = DTSTaskExecResult_Success

svr = "svr
uid = ""
pwd = ""

Set oDTSApp = CreateObject("DTS.Application")
Set oGetPkg = oDTSApp.GetPackageSQLServer(svr, uid, pwd, DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection)
Set cPkgs = oGetPkg.EnumPackageInfos("", True, "")
Set pack = CreateObject("DTS.Package")

For Each oPkg In cPkgs
desc = oPkg.Description
msgbox "Description:" + desc

If InStr(desc, "LA_") <> 0 Or InStr(desc, "LU_") <> 0 Then
pack.LoadFromSQLServer svr, uid, pwd, DTSSQLStgFlag_UseTrustedConnection , "", "", "", oPkg.Name
'GO THROUG THE GLOBAL VARIABLES, THE LAST IS THE CONNECTION NAME
For Each v in pack.GlobalVariables
msg = v.Name
Next

Set oConn = pack.GlobalVariables.Parent.Connections("" + msg)

'THIS SHOWS THE RIGHT PATH OF THE FILE
msgbox "Path: " + oConn.DataSource

'CAN'T OVERWRITE IT
oConn.DataSource = "Test"


msgbox "Packagename:" + oPkg.Name

Else
msgbox "Not a LA or LU Package!"
End If
Next

Set oGetPkg = Nothing
End Function

Post #697622
Posted Friday, April 17, 2009 2:47 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, May 20, 2009 2:42 AM
Points: 2, Visits: 53
in short:

i want to change connections properties in a child package with active x.

thx
Post #699199
« Prev Topic | Next Topic »


Permissions Expand / Collapse