471,325 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

running DTS package from windows form using C#

Hi,

Has anyone managed executing a DTS package in SQL Server 2000 from a
windows
form created using c#? Also, I specify the path of the new file
everytime through this windows form.
Please HELP!
I've see examples of windows console based execution, but nothing from
a
windows form.
Help

Feb 14 '06 #1
1 2495
Hi,

"juventusaurabh" <sa************@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hi,

Has anyone managed executing a DTS package in SQL Server 2000 from a
windows
form created using c#? Also, I specify the path of the new file
everytime through this windows form.
Please HELP!


I posted this message yesterday:

This is what I do, I create the DTS in the enterprise manager, when I'm sure
it does work as expected ( data convertion, etc) I save it in disk, this
create a DTS file, later on I use the code below to set the correct data
connections .
You can set a number of other parameters, take a look at the doc, the code
below will give you an idea of how to start
void RunPackage( string packSource, string packName, string dataSource)
{
try
{
Package2Class package = new Package2Class();
object pVarPersistStgOfHost = null;

// if you need to load from file
package.LoadFromStorageFile(
packSource,
null,
null,
null,
packName,
ref pVarPersistStgOfHost);

package._Package_Connections.Item(1).DataSource = dataSource;
package.Execute();
package.UnInitialize();

// force Release() on COM object
//
System.Runtime.InteropServices.Marshal.ReleaseComO bject(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);
Console.ReadLine();
}
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);

Console.ReadLine();
}
}

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Feb 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Frank Conte | last post: by
18 posts views Thread by rdahlstrom | last post: by
1 post views Thread by =?Utf-8?B?U3ludGF4IDM3NzA3?= | last post: by
1 post views Thread by =?Utf-8?B?Q2lhcmFuIE8nJ0Rvbm5lbGw=?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.