Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server DTS Discussion specific to Data Transformation Service with SQL Server. General SQL Server discussions should use the general SQL Server forum. Readers of the book Professional SQL Server 2000 DTS with questions specific to that book should post in that book forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server DTS section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 11th, 2010, 09:37 AM
Authorized User
 
Join Date: Jul 2006
Location: Batavia, IL, USA.
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default sp_OAGetProperty help

I'm trying to call a DTS from a stored procedure. It works if I use dts.package in visual basic, but I don't want to install sql client files on every machine I want to be able to run this. So with that, can someone tell me what I'm doing wrong? Everything seems to work up until the SetProperty statement. When I use the GetProperty method, it returns null. I have verified that @inputfile contains the value I want.

Please help before I go insane.

-- CODE --
set @server = 'MyServer'
set @PkgPwd = ''
set @PkgName = 'MyPackage'

EXEC @hr = sp_OACreate 'DTS.Package', @oPKG OUTPUT
IF @hr <> 0
BEGIN
PRINT '*** Create Package object failed'
EXEC sp_displayoaerrorinfo @oPKG, @hr
RETURN 1
END
SET @Cmd = 'LoadFromSQLServer("' + @Server +'", "", "", 256, "' + @PkgPWD + '", , , "' + @PkgName + '")'
EXEC @hr = sp_OAMethod @oPKG, @Cmd, NULL
IF @hr <> 0
BEGIN
PRINT '*** LoadFromSQLServer Failed.'
EXEC sp_displayoaerrorinfo @oPKG, @hr
RETURN 1
END
EXEC @hr = sp_OASetProperty @oPKG,'GlobalVariables("inputfile").Value', @inputfile
IF @hr <> 0
BEGIN
PRINT '*** Set Property Failed'
EXEC sp_displayoaerrorinfo @oPKG, @hr
RETURN 1
END

declare @property nvarchar(254)
exec @hr = sp_OAGetProperty @oPKG,'GlobalVariables("inputfile")',@property OUT
if @hr<>0
begin
PRINT '*** Get Property Failed'
EXEC sp_displayoaerrorinfo @oPKG, @hr
select @oPKG
RETURN 1
end
select @property
EXEC @hr = sp_OAMethod @oPKG, 'Execute'
EXEC @hr = sp_OAMethod @oPKG, 'UnInitialize'
EXEC @hr = sp_OADestroy @oPKG
-- END CODE --
  #2 (permalink)  
Old March 11th, 2010, 11:06 AM
Authorized User
 
Join Date: Jul 2006
Location: Batavia, IL, USA.
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

After some more research I've found that my syntax isn't right

it should be


EXEC @hr = sp_OASetProperty @oPKG,'GlobalVariables.item("inputfile").Value', @inputfile

Also, sp_OAGetProperty doesn't work if your output variable is nvarchar. It needs to be varchar.

Now that my input is working, I have to figure out why my package is failing :(
 


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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 05:10 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.