Gunnar Peipman's ASP.NET blog

ASP.NET, C#, SharePoint, SQL Server and general software development topics.

Sponsors

News

 
 
 
DZone MVB

Links

Social

Dumping DataTable to debug window

 

Here’s one little method I use to write out debug information when investigating some new (legacy but new to me) system. Usually I remove this method later when I know how code works. It’s maybe not the best way to debug things but it works like charm in many situations.


public void DumpDataTable(DataTable table)

{

    foreach (DataRow row in table.Rows)

    {

        Debug.Print("------------------------------------------");

 

        foreach (DataColumn col in results.Columns)

        {

            Debug.Write(col.ColumnName);

            Debug.Write("=");

            Debug.WriteLine(row[col.ColumnName]);

        }

    }

}


Hope it helps somebody :)

Posted: Apr 29 2011, 06:36 PM by DigiMortal | with no comments
Filed under:

Comments

No Comments