RSS Forums RSS
Please support our MS SQL advertiser: Programming Forums
Views: 8455 | Replies: 0
Reply
Join Date: Jul 2005
Posts: 5
Reputation: NilovSerge is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
NilovSerge NilovSerge is offline Offline
Newbie Poster

Run *.dts from T-SQL proc changing connection parameters

  #1  
Jul 16th, 2005
Hi, all!
I need to load base from ODBC-source into MSSql base using MsSql DTS at my customer's side with
automatic as much as possible('Pushing 1 buton').
I have found such an example:
DECLARE @object int
DECLARE @hr int
--create a package object
EXEC @hr = sp_OACreate 'DTS.Package', @object OUTPUT
if @hr <> 0 BEGIN
print 'error create DTS.Package'
RETURN -1
END

EXEC @hr = sp_OAMethod @object, 'LoadFromStorageFile',
NULL, 'C:\Test.dts', ''
IF @hr <> 0 BEGIN
print 'error LoadFromStorageFile'
RETURN -2
END

EXEC @hr = sp_OAMethod @object, 'Execute'
IF @hr <> 0 BEGIN
print 'Execute failed'
RETURN -3
END
It works for my DTS-file. But I need change programmatically connection parameters, login and password of connection,
not use connection parameters that I set manually in my DTS-Package.
In this packete as a source of datas "Connection Properties" with ODBC DataSource as source of my datas,
it's login and password.
Then destination is object "Connection Properties" with DataSource Microsoft Ole DB tuned to base I need,
login and password. there are about 20 objects "Transform Data Task". In doc I found function
sp_OAMethod with method "Connect":
EXEC @hr = sp_OAMethod @object, 'Connect', NULL, 'my_server', 'my_login', 'my_password'
IF @hr <> 0 BEGIN
EXEC sp_OAGetErrorInfo @object
RETURN
END
But how can I do with it as I have two bases: source and destination?

Thanks in advance,
Nilov Serge.
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 9:48 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC