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 a DTS from C# doesn't run all the time

Author  Topic 

mcmcom
Starting Member

9 Posts

Posted - 2006-10-26 : 12:05:26
Hi all,

i am new to DTS packages but am a long time C# programmer.
I have created a simple DTS package that imports records from a text file to a destination table using activeX transformations in the data transformation task. The DTS package itself runs flawlessly from Enterprise Manager but when called from C# it runs only sometimes, there are no errors reported it just Executes and then immediately quits.

Sometimes it works fine from C# and sometimes it does not, im accessing it using our sa account so permissions should not be an issue.

Below is the constructor for the calling app of the DTS package:


DTS.Package2Class package = new DTS.Package2Class();
object pVarPersistStgOfHost = null;
package.LoadFromSQLServer(
"192.168.8.8",
"sa",
"pwd",
Microsoft.SqlServer.DTSPkg80.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default,
null,
null,
null,
dtsPkg,
ref pVarPersistStgOfHost);
//remove and re-set the global variables
package.GlobalVariables.Remove("sourceFile");
package.GlobalVariables.AddGlobalVariable("sourceFile", f.FullName);
package.GlobalVariables.Remove("sourceName");
package.GlobalVariables.AddGlobalVariable("sourceName",
f.Name);
package.Execute();
package.UnInitialize();


many thanks in advance.
   

- Advertisement -