Link to home
Start Free TrialLog in
Avatar of Hynne
Hynne

asked on

How do I execute a DTS package (SQL server 2000) from a client PC using C#?

Hi

I have to make a small application, which will execute a DTS Package on a specific SQL Server 2000 server.
I'm using Visual Studio 2008 Professional.
The DTS Package is kept in the SQL Server; not in a file.
If it is possible to enumerate all DTS packages found on the server, that would be nice too.
It would be ok, if I can use a stored procedure to execute it,

I've been looking all over the internet (well, more or less :-)), but I haven't been able to find a solution.

If I use DTSRun (on the server), for some reason, it returns only the column names, when the connection (inside a package) points to "." or "(local)".
Avatar of Hynne
Hynne

ASKER

Hmm... I have now solved it, using a stored procedure, but I would still like to know if it's possible from C# directly.
Avatar of Bob Learned
SMO is a good choice for a lot of SQL Server administrative tasks.  I have some code somewhere, that I might be able to find, which runs DTS packages from C#.
Avatar of Hynne

ASKER

Hi TheLearnedOne
I would love to see it, but don't spend hours finding it, since I believe I can make my stored proc work. (I still need to find a way to enumerate the packages (and version?).
Thanks

 - Hynne
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There is a tool that comes with DTS and SQL Server 2000 that lets you select a DTS package, add the parameters that you want to use when it executes (e.g. username and password), encrypt it.  All you have to do is save that encrypted command string to either a batch file or someplace handy so that you can use it to shell out and execute the command string.  Don't have the tools to walk through to give you detailed instructions at this moment, though.
It is called DTSRunUI and the encryption is optional and I would not recommend it.  However I would expect that the author would want to have something a tad more integrated than just shelling out to a command line tool.
If you are using xp_cmdshell to run your DTS package, you should be aware that this can be a security risk if not implemented properly.