dbTalk Databases Forums  

Modify SSIS package programmatically

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


Discuss Modify SSIS package programmatically in the microsoft.public.sqlserver.dts forum.



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

Default Modify SSIS package programmatically - 01-24-2006 , 04:41 AM






Hi All,

I have a DTS package that I launch from a C# application.
The DTS package contains an Excel Connection. AS the location of the Excel
file can change dynamically, I need to be able to change the value of the
Excel Connection's "ExcelFilePath" property from my piece of C# code.

The problem is that I don't know how to access ExcelFilePath from the C#
code.
I have seen a class
Microsoft.SqlServer.Dts.Runtime.Wrapper.Connection ManagerExcelClass that has
a "ExcelFilePath" prperty but the doc says : This class supports the SQL
Server 2005 infrastructure and is not intended to be used directly from your
code. Also I don't know how to get an instance from it.

I can get an instance of the class
Microsoft.SqlServer.Dts.Runtime.ConnectionManager but that class is a
generic class for every connection managers and does not have a
ExcelFilePath property.

Is there anyone who knows how I can change that property from an external
piece of code?

Thanks in advance,

Best regards,

Francois Malgreve.



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

Default Re: Modify SSIS package programmatically - 01-24-2006 , 02:13 PM






Francois Malgreve wrote:
Quote:
Hi All,

I have a DTS package that I launch from a C# application.
The DTS package contains an Excel Connection. AS the location of the Excel
file can change dynamically, I need to be able to change the value of the
Excel Connection's "ExcelFilePath" property from my piece of C# code.

The problem is that I don't know how to access ExcelFilePath from the C#
code.
I have seen a class
Microsoft.SqlServer.Dts.Runtime.Wrapper.Connection ManagerExcelClass that has
a "ExcelFilePath" prperty but the doc says : This class supports the SQL
Server 2005 infrastructure and is not intended to be used directly from your
code. Also I don't know how to get an instance from it.

I can get an instance of the class
Microsoft.SqlServer.Dts.Runtime.ConnectionManager but that class is a
generic class for every connection managers and does not have a
ExcelFilePath property.

Is there anyone who knows how I can change that property from an external
piece of code?

Thanks in advance,

Best regards,

Francois Malgreve.


The Microsoft.SqlServer.Dts.Runtime stuff is all SQL 2005, so no good
whatsoever for DTS.

To change the file path set the DataSource property of the connection
object.

oPkg.Connections(0).DataSource = "C:\DG.xls"


--
Darren
http://www.sqldts.com
http://www.sqlis.com


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

Default Re: Modify SSIS package programmatically - 01-24-2006 , 02:14 PM



Francois Malgreve wrote:
Quote:
Hi All,

I have a DTS package that I launch from a C# application.
The DTS package contains an Excel Connection. AS the location of the Excel
file can change dynamically, I need to be able to change the value of the
Excel Connection's "ExcelFilePath" property from my piece of C# code.

The problem is that I don't know how to access ExcelFilePath from the C#
code.
I have seen a class
Microsoft.SqlServer.Dts.Runtime.Wrapper.Connection ManagerExcelClass that has
a "ExcelFilePath" prperty but the doc says : This class supports the SQL
Server 2005 infrastructure and is not intended to be used directly from your
code. Also I don't know how to get an instance from it.

I can get an instance of the class
Microsoft.SqlServer.Dts.Runtime.ConnectionManager but that class is a
generic class for every connection managers and does not have a
ExcelFilePath property.

Is there anyone who knows how I can change that property from an external
piece of code?

Thanks in advance,

Best regards,

Francois Malgreve.


The Microsoft.SqlServer.Dts.Runtime stuff is all SQL 2005, so no good
whatsoever for DTS.

To change the file path set the DataSource property of the connection
object.

oPkg.Connections(0).DataSource = "C:\DG.xls"


--
Darren
http://www.sqldts.com
http://www.sqlis.com


Reply With Quote
  #4  
Old   
Francois Malgreve
 
Posts: n/a

Default Re: Modify SSIS package programmatically - 01-25-2006 , 05:11 AM



OOPS I am using SQL 2005 SSIS and when I wrote DTS packge I should have
written IS Package...

Thhank you for your answer and sorry for the mistake.

Anyway I found the solution for SSIS and if you anyone is interested, here
is the an exploded version of the code I used:
(I guess it's easier to understand the object model with the exploded
version of the code)

Microsoft.SqlServer.Dts.Runtime.Connections packageConnections =
package.Connections; // package is a Microsoft.SqlServer.Dts.Runtime.Package
object
Microsoft.SqlServer.Dts.Runtime.ConnectionManager packageExcelConnection =
packageConnections["Excel Connection Manager"]; // name of the Excel
connection or u can use an index instead

Microsoft.SqlServer.Dts.Runtime.DtsProperties connectionProperties =
packageExcelConnection.Properties;

Microsoft.SqlServer.Dts.Runtime.DtsProperty connectionExcelFilePathProp =
connectionProperties["ExcelFilePath"];

connectionExcelFilePathProp.SetValue(packageExcelC onnection, "C:\DG.xls");

Best regards,

Francois.



"Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote

Quote:
Francois Malgreve wrote:
Hi All,

I have a DTS package that I launch from a C# application.
The DTS package contains an Excel Connection. AS the location of the
Excel file can change dynamically, I need to be able to change the value
of the Excel Connection's "ExcelFilePath" property from my piece of C#
code.

The problem is that I don't know how to access ExcelFilePath from the C#
code.
I have seen a class
Microsoft.SqlServer.Dts.Runtime.Wrapper.Connection ManagerExcelClass that
has a "ExcelFilePath" prperty but the doc says : This class supports the
SQL Server 2005 infrastructure and is not intended to be used directly
from your code. Also I don't know how to get an instance from it.

I can get an instance of the class
Microsoft.SqlServer.Dts.Runtime.ConnectionManager but that class is a
generic class for every connection managers and does not have a
ExcelFilePath property.

Is there anyone who knows how I can change that property from an external
piece of code?

Thanks in advance,

Best regards,

Francois Malgreve.



The Microsoft.SqlServer.Dts.Runtime stuff is all SQL 2005, so no good
whatsoever for DTS.

To change the file path set the DataSource property of the connection
object.

oPkg.Connections(0).DataSource = "C:\DG.xls"


--
Darren
http://www.sqldts.com
http://www.sqlis.com



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.