dbTalk Databases Forums  

Change connection data source using VB

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


Discuss Change connection data source using VB in the microsoft.public.sqlserver.dts forum.



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

Default Change connection data source using VB - 02-09-2004 , 10:51 PM






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 package
Set oDTSApp = New DTS.Applicatio
Set oGetPkg = oDTSApp.GetPackageSQLServer(svr, uid, pwd, auth
Set cPkgs = oGetPkg.EnumPackageInfos("", True, "") 'EnumPackageInfos(PackageName,ReturnLatest,Package ID
Set oGetPkg = Nothin

'Load each package and carry out the required change
For Each oPkg In cPkg
On Error GoTo ErrorHandle
pkgname = oPkg.Nam
myPkg.LoadFromSQLServer svr, uid, pwd, auth, , , , pkgnam

'Update connection datasourc
Set cConns = myPkg.Connection
For Each oConn In cConn
If oConn.ConnectionProperties("Data Source") = "WNCHASQ02" The
oConn.ConnectionProperties("Data Source") = "(local)
Debug.Print myPkg.Name & ": " & oConn.Nam
End I
Nex
'Need to reset the package to be empty before the next one begin
myPkg.UnInitializ
Set myPkg = Nothin
Next oPkg

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Change connection data source using VB - 02-10-2004 , 03:12 AM






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

Quote:
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????
Quote:
'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



Reply With Quote
  #3  
Old   
Kristen
 
Posts: n/a

Default Re: Change connection data source using VB - 02-11-2004 , 08:51 PM



Yeah! I thought I had killed the first one accidentally
so I reposted!

Quote:
-----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


.


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.