.net - C# StreamWriter not writing correctly -


i pulling data sproc , writing each column file. 1 of columns pulling memo field allowing 4096 characters , hard carriage returns. have updated query remove tabs , returns, seems work. when export query results file memo column on 1 line. however, when write data file using stream writer splits data on multiple lines. here appreciated.

c# code:

    streamwriter sw = new streamwriter("c:\\temp\\test.txt");     dataset ds = getdata(); //call sproc, return data     foreach(datarow dr in ds) {        sw.writeline(dr["column1"] + "|" + dr["memocolumn"] + "|" + dr["column3"]);     } 

sql query:

    select replace(replace(replace(isnull(memocolumn, ''), char(13), ' '), char(10), ''), char(9), '')     table1 

following should work, there might typos, process should functional.

    using (streamwriter sw = new streamwriter("c:\\temp\\test.txt"))      {      dataset ds = getdata(); //call sproc, return data      foreach(datarow dr in ds.rows)       {        var column = string.isnullorempty((dr["memocolumn"].tostring()) ? string.empty :                      dr["memocolumn"].tostring().replace(environment.newline, string.empty);         sw.writeline("{0}|{1}|{2}", dr["column1"], column, dr["column3"]);      }     } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -