开发者

How to use EzAPI FlatFile Source in SSIS?

开发者 https://www.devze.com 2023-01-14 16:38 出处:网络
I am using the EzAPI to create a dataflow with FlatFile Source public class EzOleDbToFilePackage : EzSrcDestPackage<EzFlatFileSource, EzFlatFileCM, EzOleDbDestination, EzSqlOleDbCM>

I am using the EzAPI to create a dataflow with FlatFile Source

public class EzOleDbToFilePackage : EzSrcDestPackage<EzFlatFileSource, EzFlatFileCM, EzOleDbDestination, EzSqlOleDbCM>

Using the example from http://blogs.msdn.com/b/mattm/archive/2008/12/30/ezapi-alternative-package-creation-api.aspx I am trying to use a flat file source. However in the flat file source/开发者_如何转开发connection I am unable to map the columns from the flat file.

Is there something like Dest.DefineColumnsInCM() for the zFlatFileSource?

In the BIDM when I open the created package, I see that the EzFlatFileCM is saying Columns are not defined for this connection manager. As soon as I click on Columns it automatically detects everything and the error goes away. What method do I need to call in my code to get the EzFlatFileSource to automatically pick these columns up?


From the folks at http://blogs.msdn.com/b/mattm/archive/2008/12/30/ezapi-alternative-package-creation-api.aspx

I believe the logic which automatically determines the source columns is built into the flat file connection manager UI, and isn't accessible via code (something I'd definitely like to change). From the code samples I have, it looks like you need to define your columns manually.

ex.

       pkg.SrcConn.Unicode = (fileFormat == FileFormat.UNICODE);

       pkg.SrcConn.ConnectionString = srcFile;

       pkg.SrcConn.Columns.Add().DataType = dataType;

       pkg.SrcConn.Columns[0].ColumnType = "Delimited";

       pkg.SrcConn.ColumnNamesInFirstDataRow = false;

       pkg.SrcConn.ColumnDelimiter = ",";

       pkg.SrcConn.RowDelimiter = "\r\n";

       pkg.SrcConn.TextQualifier = "\"";

       pkg.SrcConn.Columns[0].TextQualified = testObject.textQualified;

       if (!pkg.Source.OutputColumnExists("col0"))

       {

           pkg.Source.InsertOutputColumn("col0");

       }

       pkg.Source.SetOutputColumnDataTypeProperties("col0", dataType, testObject.length, testObject.precision, testObject.scale, testObject.codePage);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号