The reason that only the last row from the database is written to the file, is because you are recreating the file each time you call this
method. You need to create and close the file outside
of the loop
Do something like this instead:
public void Input0_ProcessFile()
using (var sw = new StreamWriter("c:\\temp\\test.txt"))
foreach (var row in datainput)
Note I've also put the file into a sub-folder. It is bad practice to store files on the root folder C:\ and in many cases you will be prevented from doing so, particularly if this script is running on the server. This may be the error you encountered.
Also note that I've changed the signature of your method to pass in the reference to the StreamWriter
public override void Input0_ProcessInputRow(StreamWriter sw, Input0Buffer Row)
Here is the MSDN Reference (there are more links in the sidebar to the page in the link). How to: Write Text to a File
[Edit] As an aside consider using
instead of all of those escape characters.
Another alternative would be to convert the data into and XML file and use an HTML Template/XSLT to transform the data into a "report" - see Creating and Populating an HTML Template (Windows CE .NET 4.2)