Sunday, March 11, 2012

Calling a DTS Stored Procedure from ASP.NET

I have a stored procedure that calls a DTS package to grab a text file that has been uploaded to the server and merge it with a table on the database. The DTS package works woderfully in SQL, as does the the file upload. The problem arrises when I create a stored procedure to run the DTS package. I know that you have to shell out and do a command line on the SQL server (and I think that I got the syntax correct) but its calling the Stored Procedure in the ASP.NET app that is causing me hardship. Here is the code that I have so far:

Stored Procedure:

CREATE PROCEDURE spSampleData AS exec master..xp_cmdshell 'dtsrun /SZEUS\sqlServer113 /NdtsPackage /UuserID /Ppassword'
GO

VB to run DTS:

Dim myCommand As SqlCommand
myCommand.CommandType = CommandType.StoredProcedure
myCommand.CommandText = "spSampleData"
myCommand.ExecuteNonQuery()

I'm not sure what I am doing wrong but any help would be great.

Thanks!Your code seems ok on the face of it. What is the error message that is generated? Or does just nothing happen?

These links might be helpful:

DTS Cookbook for .Net

Execute a package from T-SQL This one describes your current method but offers another alternative too.|||Thank you so much for the links - I'll check them out. So here are the errors...

When running in Query Analyzer:

-"DTSRun: Cannot create COM Server to load and execute DTS Package. Error -2147024769 (8007007F): The specified procedure could not be found. "

I thought this was because some of the DLLs weren't registered but that isn't it.

-"I tried to schedule it as a job, before I got this just to see, and it gave me a a long hex dec error that was in a windows alert box, so I didn't even worry with that. But it was:"

The procedure entry point ?SQLUIUpdateRegistryFromResource could not be located in the dynamic link library SQLRESLD.dll

In the Webform, it was your typical:

"Object reference not set to an instance of an object" error... So I'm at a loss.|||I hate those sorts of problems. I Googled the error message and ended up with this link.

No comments:

Post a Comment