![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm trying to update all connections in all packages on the server if the specified value is found in the connection data source. The code seems to |
|
'Connect to server and get a list of all packages Set oDTSApp = New DTS.Application Set oGetPkg = oDTSApp.GetPackageSQLServer(svr, uid, pwd, auth) Set cPkgs = oGetPkg.EnumPackageInfos("", True, "") 'EnumPackageInfos(PackageName,ReturnLatest,Package ID ) Set oGetPkg = Nothing 'Load each package and carry out the required changes For Each oPkg In cPkgs On Error GoTo ErrorHandler pkgname = oPkg.Name myPkg.LoadFromSQLServer svr, uid, pwd, auth, , , , pkgname 'Update connection datasource Set cConns = myPkg.Connections For Each oConn In cConns If oConn.ConnectionProperties("Data Source") = "WNCHASQ02" Then oConn.ConnectionProperties("Data Source") = "(local)" Debug.Print myPkg.Name & ": " & oConn.Name End If Next 'Need to reset the package to be empty before the next one begins myPkg.UnInitialize Set myPkg = Nothing Next oPkg |
#3
| |||
| |||
|
|
-----Original Message----- There's a remarkably similar question posted shortly after this, try that for my answer. -- Darren Green http://www.sqldts.com "Kristen" <khodgesN (AT) SPAMcsr (DOT) com.au> wrote in message news:93DEE0FA-C44B-4972-9623-BA6BEAE22F49 (AT) microsoft (DOT) com... I'm trying to update all connections in all packages on the server if the specified value is found in the connection data source. The code seems to work fine as in there are no unexpected errors or halts except that the change doesn't actually occur. After the script runs (with no unexpected errors) I open a package to confirm the change but the connection still has the old data source! Any thoughts???? 'Connect to server and get a list of all packages Set oDTSApp = New DTS.Application Set oGetPkg = oDTSApp.GetPackageSQLServer(svr, uid, pwd, auth) Set cPkgs = oGetPkg.EnumPackageInfos("", True, "") 'EnumPackageInfos(PackageName,ReturnLatest,Package ID ) Set oGetPkg = Nothing 'Load each package and carry out the required changes For Each oPkg In cPkgs On Error GoTo ErrorHandler pkgname = oPkg.Name myPkg.LoadFromSQLServer svr, uid, pwd, auth, , , , pkgname 'Update connection datasource Set cConns = myPkg.Connections For Each oConn In cConns If oConn.ConnectionProperties("Data Source") = "WNCHASQ02" Then oConn.ConnectionProperties("Data Source") = "(local)" Debug.Print myPkg.Name & ": " & oConn.Name End If Next 'Need to reset the package to be empty before the next one begins myPkg.UnInitialize Set myPkg = Nothing Next oPkg . |
![]() |
| Thread Tools | |
| Display Modes | |
| |