Friday, March 23, 2012

Viewing contents of a DataSet or DataView in quick watch, C#

[Visual Studio] Have you ever faced any issue in visualizing the contents of a dataset while debugging a problem in Visual Studio? Generally we've a habit of  viewing the contents of a collection while debugging a particular problem but you can't do the same with DataSet. Here is a quick tip to view DataSet contents in QuickWatch.

Visual Studio Visualizers
This is what MSDN says about visualizers: A visualizer creates a dialog box or another interface to display a variable or object in a manner that is appropriate to its data type. For example, an HTML visualizer interprets an HTML string and displays the result as it would appear in a browser window; a bitmap visualizer interprets a bitmap structure and displays the graphic it represents. Some visualizers enable you to modify as well as view the data.
The Visual Studio debugger includes five standard visualizers.
1,2,3. The text, HTML, and XML visualizers, all of which work on string objects;
4. the WPF Tree visualizer, for displaying the properties of a WPF object visual tree;
5. the dataset visualizer, which works for DataSet, DataView, and DataTable objects. This is the one we should use in order to solver our problem.

Visualizers are represented in the debugger by a magnifying glass icon. When you see the magnifying glass icon in a DataTip, in a debugger variables window, or in theQuickWatch dialog box, you can click the magnifying glass to select a visualizer appropriate to the data type of the corresponding object.

Following figure will explain the way to use it:


Also note that: Visualizers are not supported on the Compact Framework.

No comments:

Post a Comment