dbTalk Databases Forums  

Running DTS packages from .net

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Running DTS packages from .net in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mark
 
Posts: n/a

Default Running DTS packages from .net - 07-21-2004 , 11:23 AM






Hi,

I am trying to programatically run a DTS package from .Net (C#) and and ideally would like to see the "Executing DTS Package" and "Package Execution Results" windows displayed.

I've reviewed dtsrun, dtsrunui utilities and KB319985 articles.

If the dtsrun utilitity had a argument indicating to display "Executing DTS Package" and "Package Execution Results" windows that would be work, but it doesn't.

If the dtsrunui utilitity accepted arguments for the server, package, etc... that would be great, but it doesn't.

I could use the package2Class.execute method with and the events as in KB319985, but would have to write my own "Executing DTS Package" and "Package Execution Results" windows.

So my question is this - does anyony know how to programatically run a DTS package from .Net (C#) and and get see the "Executing DTS Package" and "Package Execution Results" windows displayed ?

Thanks,

Mark



Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Running DTS packages from .net - 07-21-2004 , 11:36 AM






To leverage the MS written windows you need to use SQL-NS to execute the
package as opposed to the object model.

You can use the simple SQL-NS demo project (VB6) that ships with SQL Server
to check this out.

C:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Samples\sqlns


Darren Green
http://www.sqldts.com


"Mark" <Mark (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi,

I am trying to programatically run a DTS package from .Net (C#) and and
ideally would like to see the "Executing DTS Package" and "Package Execution
Results" windows displayed.
Quote:
I've reviewed dtsrun, dtsrunui utilities and KB319985 articles.

If the dtsrun utilitity had a argument indicating to display "Executing
DTS Package" and "Package Execution Results" windows that would be work, but
it doesn't.
Quote:
If the dtsrunui utilitity accepted arguments for the server, package,
etc... that would be great, but it doesn't.

I could use the package2Class.execute method with and the events as in
KB319985, but would have to write my own "Executing DTS Package" and
"Package Execution Results" windows.
Quote:
So my question is this - does anyony know how to programatically run a
DTS package from .Net (C#) and and get see the "Executing DTS Package" and
"Package Execution Results" windows displayed ?
Quote:
Thanks,

Mark





Reply With Quote
  #3  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Running DTS packages from .net - 07-21-2004 , 11:37 AM



If you want to see the window as per EM executing the package then you can
probably get what you need from using the SQLNamespace library

Have a look at this

http://www.databasejournal.com/featu...le.php/1486471

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"Mark" <Mark (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi,

I am trying to programatically run a DTS package from .Net (C#) and and
ideally would like to see the "Executing DTS Package" and "Package Execution
Results" windows displayed.
Quote:
I've reviewed dtsrun, dtsrunui utilities and KB319985 articles.

If the dtsrun utilitity had a argument indicating to display "Executing
DTS Package" and "Package Execution Results" windows that would be work, but
it doesn't.
Quote:
If the dtsrunui utilitity accepted arguments for the server, package,
etc... that would be great, but it doesn't.

I could use the package2Class.execute method with and the events as in
KB319985, but would have to write my own "Executing DTS Package" and
"Package Execution Results" windows.
Quote:
So my question is this - does anyony know how to programatically run a
DTS package from .Net (C#) and and get see the "Executing DTS Package" and
"Package Execution Results" windows displayed ?
Quote:
Thanks,

Mark





Reply With Quote
  #4  
Old   
Mark
 
Posts: n/a

Default Re: Running DTS packages from .net - 07-22-2004 , 09:33 AM



There were lots of gotchas along the way, but I finally got it working… Thanks for the pointers guys…

//
// Connect to Enterprise Manager at the SQL Server Group level
//
SQLNamespace oSQLNS = new SQLNamespaceClass();
string sConnStr = "Server=SCR4;Trusted_Connection=Yes;SrvGrp=SQL Server Group";
object oConnStr = (object)sConnStr;
oSQLNS.Initialize("DTSRun",SQLNS.SQLNSRootType.SQL NSRootType_Server,ref oConnStr, 0);

int hRootItem;
hRootItem = oSQLNS.GetRootItem();
//
// Get a handle to the appropriate package
//
int hDTSPackages;
int hDTSLocalPackages;
int hDTSPackage;

hDTSPackages = oSQLNS.GetFirstChildItem(hRootItem,SQLNS.SQLNSObje ctType.SQLNSOBJECTTYPE_DTSPKGS,"");
hDTSLocalPackages = oSQLNS.GetFirstChildItem(hDTSPackages,SQLNS.SQLNSO bjectType.SQLNSOBJECTTYPE_DTS_LOCALPKGS,"");
hDTSPackage = oSQLNS.GetFirstChildItem(hDTSLocalPackages,SQLNSOb jectType.SQLNSOBJECTTYPE_DTSPKG,"Test_dotnet_dts_r un");
//
// Create the SQLNamespace object using the package handle
//
SQLNamespaceObject oSQLNSObj;
oSQLNSObj = oSQLNS.GetSQLNamespaceObject(hDTSPackage);
//
// Run the package
//
oSQLNSObj.ExecuteCommandByName("Run Package",0,SQLNS.SQLNSModality.SQLNamespace_Prefer Modal);


"Mark" wrote:

Quote:
Thanks for the pointers Darren an Allan, this appears to be exactly what I need.

I've tried converting to C# and have run into some difficulties... In particular the the VB examples shows a connection string as the the 3 argument on the SQLNS.Initialize method

gobjSQLNS.Initialize "SQL Namespace Object Browser", cbRootType.ListIndex, CStr(strConnect), hWnd

However, VS .Net Intellisense and the reference are showing a optional argument of ref object pRootInfo as the 3 argument. - http://msdn.microsoft.com/library/de...s_ref_89wx.asp

Bottom line - does anyone know where a C# example of using the SQL-NS ?

Thanks,

Mark

"Darren Green" wrote:

To leverage the MS written windows you need to use SQL-NS to execute the
package as opposed to the object model.

You can use the simple SQL-NS demo project (VB6) that ships with SQL Server
to check this out.

C:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Samples\sqlns


Darren Green
http://www.sqldts.com


"Mark" <Mark (AT) discussions (DOT) microsoft.com> wrote in message
news:E3ADB90F-5D9E-47FF-9A5C-40945D9A10D1 (AT) microsoft (DOT) com...
Hi,

I am trying to programatically run a DTS package from .Net (C#) and and
ideally would like to see the "Executing DTS Package" and "Package Execution
Results" windows displayed.

I've reviewed dtsrun, dtsrunui utilities and KB319985 articles.

If the dtsrun utilitity had a argument indicating to display "Executing
DTS Package" and "Package Execution Results" windows that would be work, but
it doesn't.

If the dtsrunui utilitity accepted arguments for the server, package,
etc... that would be great, but it doesn't.

I could use the package2Class.execute method with and the events as in
KB319985, but would have to write my own "Executing DTS Package" and
"Package Execution Results" windows.

So my question is this - does anyony know how to programatically run a
DTS package from .Net (C#) and and get see the "Executing DTS Package" and
"Package Execution Results" windows displayed ?

Thanks,

Mark






Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.