Showing posts with label flat. Show all posts
Showing posts with label flat. Show all posts

Sunday, 12 February 2012

Configuring Flat File Connection Programmatically?

I am programmatically creating a package in c#. I need this package to contain a flat file connection manager. I have been successfully able to create the connection manager with the following code:

Package p = new Package(); //New package

ConnectionManager cm = p.Connections.Add("FLATFILE"); //Add a flat file connection manager

cm.ConnectionString = "C:\Dev\myTestFile.txt"; //Set up the connection string

At this point, I want to configure the flat file specific properties of the connection manager (RowDelimiter, HeaderRowDelimiter, etc.). The problem is that the properties collection of the ConnectionManager object is read only. I think I could access the inner object of the connection manager and set the properties in the following way:

ConnectionManagerFlatFileClassffClass = (ConnectionManagerFlatFileClass) cm.InnerObject; //Get the inner object

ffClass .RowDelimiter = "{LF}"; //Set the properties here

Even if this would work, I do not like the solution b/c the BOL states that the ConnectionManagerFlatFileClass "supports the SQL Server 2005 infrastructure and is not intended to be used directly from your code". Does anyone know the "right" way to set these properties?

Many thanks in advance!

David

Figured it out - it looks like I spoke too soon - the BOL does indeed state how to do this:

cm.Properties["RowDelimiter"].SetValue(cm, "LF");

Friday, 10 February 2012

Configure SSIS package

I would like to develop a SSIS package where in there are 'X' number of input data sources like flat files, MS Access mdb files etc. The details about the number of input data sources, type of each data sources, the physical path of the data file, name os database server, username for the database server, password for the database server etc has to come from the configuration file.

Can anyone help on this ?

While you can use configurations to set things like database connections, user names, etc, SSIS packages can't change the metadata used in a dataflow at runtime. They aren't self-modifying. If you are trying to build a "generic" package that can handle any data dynamically, you will need to build an application that creates the package on the fly. SSIS has a good API, so this is certainly in the realm of possiblity, but it is still a lot of work.