conversion of db file in to csv file
C#
2
Posts
2
Posters
0
Views
1
Watching
-
hi I want to save my database table contents in to CSV format using C# . how can i do this. This is very urgent plz reply ASAP. Thanks in advance Alok
-
hi I want to save my database table contents in to CSV format using C# . how can i do this. This is very urgent plz reply ASAP. Thanks in advance Alok
A csv format replaces tabs with commas so if you can read your table then you can convert from datatable to csv as shown in following pseudo-code:
DataTable myTable = GetTableContents(tableName); StringBuilder sb = new StringBuilder(); foreach (DataRow row in myTable.Rows){ for (int colIndex = 0; colIndex < myTable.Columns.Count){ if (colIndex != 0) sb.Append(",") sb.Append(row[colIndex].ToString()); } sb.Append("\n"); //or use "\r\n" }