Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view a DataTable while debugging

I'm just getting started using ADO.NET and DataSets and DataTables. One problem I'm having is it seems pretty hard to tell what values are in the data table when trying to debug.

What are some of the easiest ways of quickly seeing what values have been saved in a DataTable? Is there someway to see the contents in Visual Studio while debugging or is the only option to write the data out to a file?

I've created a little utility function that will write a DataTable out to a CSV file. Yet the the resulting CSV file created was cut off. About 3 lines from what should have been the last line in the middle of writing out a System.Guid the file just stops. I can't tell if this is an issue with my CSV conversion method, or the original population of the DataTable.

Update

Forget the last part I just forgot to flush my stream writer.

like image 575
Eric Anastas Avatar asked Aug 26 '09 19:08

Eric Anastas


People also ask

How do I view a DataTable?

You can access the contents of a DataTable by using the Rows and Columns collections of the DataTable. You can also use the Select method to return subsets of the data in a DataTable according to criteria including search criteria, sort order, and row state.

How do I view DataTable in Visual Studio?

To use it, break into your code, mouse over your DataSet, expand the quick watch, view the Tables, expand that, then view Table[0] (for example).

How do I open Visualizer DataSet?

The DataSet Visualizer allows you to view the contents of a DataSet, DataTable, DataView, or DataViewManager object. You can access this visualizer by clicking on the magnifying glass icon that appears next to the Value for one of those objects in a debugger variables window or in a DataTip.

How do you view variables in VS code?

Display a data tipSet a breakpoint in your code, and start debugging by pressing F5 or selecting Debug > Start Debugging. When paused at the breakpoint, hover over any variable in the current scope. A data tip appears, showing the name and current value of the variable.


2 Answers

With a break point set, after the DataTable or DataSet is populated, you can see a magnifying glass if you hover over the variable. If you click on it, it will bring up the DataTable Visualizer, which you can read about here.

In this image you see below, dt is my DataTable variable and the breakpoint was hit a few lines below allowing me to hover over this value. Using Visual Studio 2008.

alt text

DataTable Visualizer (image credit):
alt text

like image 173
RSolberg Avatar answered Oct 09 '22 22:10

RSolberg


set the break point on the dataset/datatable(f9 shortcut key for break point) and run your application (f5 is the shortcutkey ) When the break point comes mouse hover the dataset/datatable click on the glass shown in the hover image in visual studio .

Note : check compilation debug="true" is true in web config .Else visual studio wont go for debugging .

like image 24
anishMarokey Avatar answered Oct 09 '22 21:10

anishMarokey