Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Dumping DataTable to debug window

DZone's Guide to

Dumping DataTable to debug window

·
Free Resource
Here’s one little method I use to write out debug information when investigating a new (legacy but new to me) system. Usually I remove this method later when I know how the 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 :)
Topics:

Published at DZone with permission of Gunnar Peipman, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}