User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 423,879 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,196 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 8160 | 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.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 4:37 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC