Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Calling DTS from C# program

Author  Topic 

eric_ht
Starting Member

37 Posts

Posted - 2007-07-25 : 13:11:27
I am trying to execute a DTS package from a C# program. I found some code (posted below), added all the references and everything seems to be in working order. The code executes, no errors are thrown but the package is never executed. To try and see if this code is really working or not, I first changed the name of the server to an invalid name and executed it. I received an invalid server message. I then changed the user id and password to invalids and received invalid error messages. I then changed the name of the DTS package to one that does not exist and I got an invalid DTS package error. So that tells me it's not having authentication problems and it is finding the package. Any clues as to what is going on here?

thanks

try
{
Package2Class package = new Package2Class();
object pVarPersistStgOfHost = null;


package.LoadFromSQLServer(
"myserver",
"my_userid",
"my_password",
DTSSQLServerStorageFlags.DTSSQLStgFlag_Default,
null,
null,
null,
"RemoteDTS",
ref pVarPersistStgOfHost);

package.Execute();
package.UnInitialize();

// force Release() on COM object
//
System.Runtime.InteropServices.Marshal.ReleaseComObject(package);
package = null;

}

catch(System.Runtime.InteropServices.COMException e)
{
Console.WriteLine("COMException {0}", e.ErrorCode.ToString() );
Console.WriteLine("{0}", e.Message);
Console.WriteLine("{0}", e.Source);
Console.WriteLine("Stack dump\n{0}\n", e.StackTrace);
}
catch(System.Exception e)
{
Console.WriteLine("Exception");
Console.WriteLine("{0}", e.Message);
Console.WriteLine("{0}", e.Source);
Console.WriteLine("Stack dump\n{0}\n", e.StackTrace);
}

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-07-25 : 15:46:40
Set profiler trace to see what happens.
Go to Top of Page

eric_ht
Starting Member

37 Posts

Posted - 2007-07-26 : 08:06:22
Thanks for the info. I turned on Profiler using some of the standard templates but when the package was invoked/executed nothing appears. So does that mean it's really not being found or is their another template that should be used for tracing dts?
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-07-26 : 23:20:45
Choose event to trace based on what the package does.
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2007-07-27 : 04:42:31
"dtsrun" is a command line utility that will let you execute dts-packages. You can either execute it directly from your C#-code (if you have proper access) or you can create an unscheduled sql server job that executes dtsrun, and the execute the system stored procedure "sp_start_job" from your C#-code. Look up "dtsrun" and "sp_start_job" in Books Online for parameters and stuff...

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

eric_ht
Starting Member

37 Posts

Posted - 2007-07-27 : 12:55:13
Thanks again guys. I have used dtsrun in the past and it does work for me. Right now I'm just frustrated because this method is supposed to work..and I'm determined to find out why it's not!!
Go to Top of Page
   

- Advertisement -