|
Home > Archive > MS SQL Server DTS > January 2006 > Modify SSIS package programmatically
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Modify SSIS package programmatically
|
|
| Francois Malgreve 2006-01-24, 7:23 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. ConnectionManagerExc
elClass 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.
| |
| Darren Green 2006-01-24, 8:24 pm |
| 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. ConnectionManagerExc
elClass 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
| |
| Darren Green 2006-01-24, 8:24 pm |
| 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. ConnectionManagerExc
elClass 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
| |
| Francois Malgreve 2006-01-26, 4:58 pm |
| 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 packageExcelConnecti
on =
packageConnections["Excel Connection Manager"]; // name of the Excel
connection or u can use an index instead
Microsoft.SqlServer.Dts.Runtime.DtsProperties connectionProperties
=
packageExcelConnecti
on.Properties;
Microsoft.SqlServer.Dts.Runtime.DtsProperty connectionExcelFileP
athProp =
connectionProperties
["ExcelFilePath"];
connectionExcelFileP
athProp. SetValue(packageExce
lConnection, "C:\DG.xls");
Best regards,
Francois.
"Darren Green" <darren.green@reply-to-newsgroup-sqldts.com> wrote in message
news:uRakCLSIGHA.2212@TK2MSFTNGP15.phx.gbl...
> Francois Malgreve wrote:
>
> 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
|
|
|
|
|