DataSet text representation.  
Author Message
vtortola





PostPosted: .NET Framework Data Access and Storage, DataSet text representation. Top

Hi!

I don't know where i must put this, if is the erroneous forum... moderator please.. :D

Well, i must send a DataSet via eMail, i can do it with .GetXml() method, but i'm looking for a more eye-candy representation than XML, somethig like :



--------------------------------
| colum 1 | colum 2 | comlum 3 |
--------------------------------
| value | value | value |
--------------------------------



Somebody know some method/funcion/algorritm to do it :)

Regards.



.NET Development28  
 
 
TaylorMichaelL





PostPosted: .NET Framework Data Access and Storage, DataSet text representation. Top

There is no pretty printing method for this. You'll need to do it by hand. What will make it harder is the fact that positioning is based on the size of the text. Your best bet is to probably generate an HTML e-mail and store the data in a table so at least the columns line up properly.

Michael Taylor - 11/27/06


 
 
V.Tortola





PostPosted: .NET Framework Data Access and Storage, DataSet text representation. Top

Ok, thanks :)

Regards.


 
 
V.Tortola





PostPosted: .NET Framework Data Access and Storage, DataSet text representation. Top

A posible solution:



private string DataSet2Text(DataSet DS)
{
StringBuilder Resultado = new StringBuilder();
foreach (DataColumn col in DS.Tables[0].Columns)
Resultado.Append(col.Caption.Substring(0, 3) + "\t");
Resultado.Append('\n');
foreach (DataRow dr in DS.Tables[0].Rows)
{
foreach (object o in dr.ItemArray)
Resultado.Append(o.ToString().PadLeft(3, '0') + "\t");
Resultado.Append('\n');
}
return Resultado.ToString();
}



Regards.