Hi
I am Trying to import a Fixed Length File Using SSIS programatically.
My connectionManager code is
connectionManager = package.InnerObject.Connections.Add("FLATFILE");
connectionManager.ConnectionString = "C:\FIXED.TXT";
connectionManager.Name = "SSIS Connection Manager for Files";
connectionManager.Description = string.Concat("SSIS Connection Manager");
connectionManager.Properties["ColumnNamesInFirstDataRow"].SetValue(connectionManager, TRUE);
connectionManager.Properties["RowDelimiter"].SetValue(connectionManager, "\r\n");
connectionManager.Properties["Format"].SetValue(connectionManager, "FixedWidth");
connectionManager.Properties["HeaderRowDelimiter"].SetValue(connectionManager, "\r\n");
and my column mapping code is
RuntimeWrapper.IDTSConnectionManagerFlatFile90 flatFileConnection =
connectionManager.InnerObject as RuntimeWrapper.IDTSConnectionManagerFlatFile90;
RuntimeWrapper.IDTSConnectionManagerFlatFileColumn90 column;
RuntimeWrapper.IDTSConnectionManagerFlatFileColumns90 columns;
RuntimeWrapper.IDTSName90 name;
DataTable schemaTable = DataSource.GetSchemaTable();
foreach (DataRow row in schemaTable.Rows)
{
string colName = row["ColumnName"] as string;
column = flatFileConnection.Columns.Add();
if (schemaTable.Rows.IndexOf(row) == (schemaTable.Rows.Count - 1))
{
column.ColumnDelimiter =delimitedDataSource.HeaderRowDelimiter;
}
column.ColumnType = "FixedWidth";
column.TextQualified = delimitedDataSource.TextQualifier != null;
flatFileConnection.ColumnNamesInFirstDataRow = true;
column.ColumnWidth = 5;
column.MaximumWidth = 5;
column.DataType = RuntimeWrapper.DataType.DT_WSTR;
column.DataPrecision = 0;
column.DataScale = 0;
name = (RuntimeWrapper.IDTSName90)column;
name.Name = colName;
}
This code is importing datas wrongly. Also importing the Header row
My file content is
data1,data2,data3
111112222233333
444445555566666
but it is importing like this ,
data1 data2 data3
a3 1 11112 22223
3333 4444 45555
Can any one help me to solve this and import a fixed length file using SSIS programatically
Regards
Hari