Assuming you only have 1 table in the dataset, it should be as simple as:
int numColumns = ds.Tables[0].Columns.Count;
for(int row=0; row<ds.Tables[0].Rows.Count; rows++)
{
for(int col=0; col < numColumns - 1; col++)
{
writer.Write(ds.Tables[0].Rows[row][col].ToString() + '\t');
}
writer.WriteLine(ds.Tables[0].Rows[row][numColumns - 1].ToString());
}
Where:
ds = DataSet
writer = a type derived from TextWriter (example: StreamWriter is
probably your best bet)
Note - I make no claim that this is the fastest, most efficient method,
but it should do the job.
If you have more than one table in your dataset, you have to decide how
you want to handle the other tables - do they each get their own file?
Joshua Flanagan
http://flimflan.com/blog
Deepa wrote:
Hi
I have a DataSet file (xml) which I need to convert it into a tab delimited
file. I need to write a C# console application for doing the same. Can anyone
help me out with the code to do it? I'd appreciate any kind of help.
Thanks