Read Text File from Flat File Connection Manager SSIS


hello experts,

i createing one task (user control) in ssis. have property grid in gui , 2 buttons (ok & cancle).

propertygrid has properties sourceconnection, outputconnection etc....right able populate connections in list box next source , output property.

 

now question guys depending on source connection should read text file associated connection manager. after validation should pick header (first line of text file bases on record type) , write new file when task executed. have following code reference. please let me know going in right direction or not..

what should go here ?

->under class a

public override dtsexecresult execute(connections connections, variabledispenser variabledispenser, idtscomponentevents componentevents, idtslogging log, object transaction)

{

 

//some code read file , write new file

return dtsexecresult.success;

}

 

public const string property_task = "customerrorcontrol";

public const string property_sourceconnection = "sourceconnection";

 

public void loadfromxml(xmlelement node, idtsinfoevents infoevents)

{

if (node.name != property_task)

{

throw new exception(string.format("invalid task element '{0}' in loadfromxml.", node.name));

}

else

{

try

{

_sourceconnectionid = node.attributes.getnameditem(property_sourceconnection).value;

}

catch (exception ex)

{

infoevents.fireerror(0, "loadfromxml", ex.message, "", 0);

}

}

}

public void savetoxml(xmldocument doc, idtsinfoevents infoevents)

{

try

{

// // create task element

xmlelement taskelement = doc.createelement("", property_task, "");

doc.appendchild(taskelement);

// // save source fileconnection

xmlattribute sourcefileattribute = doc.createattribute(property_sourceconnection);

sourcefileattribute.value = _sourceconnectionid;

taskelement.attributes.append(sourcefileattribute);

}

catch (exception ex)

{

infoevents.fireerror(0, "savexml", ex.message, "", 0);

}

}

 

in ui class there ok click event.

private void btnok_click(object sender, eventargs e)

{

try

{

 

_taskhost.properties[customerrorcontrol.property_sourceconnection].setvalue(_taskhost, propertygrid1.text);

btnok.dialogresult = dialogresult.ok;

}

catch (exception ex)

{

console.writeline(ex);

}

#endregion

}

anyone please reply solution...please

 



SQL Server  >  SQL Server Integration Services



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........