Click here to Skip to main content
6,630,586 members and growing! (15,394 online)
Email Password   helpLost your password?
Database » Database » ADO.NET     Intermediate

DataSet Watch 2.0

By Osama Abbas

An enhanced DataSet Visualizer for Visual Studio 2005.
C# 2.0, Windows, .NET 2.0VS2005, Dev
Posted:27 Oct 2006
Updated:29 Dec 2006
Views:57,007
Bookmarked:87 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
15 votes for this article.
Popularity: 5.32 Rating: 4.52 out of 5

1

2

3
5 votes, 33.3%
4
10 votes, 66.7%
5

Sample Image - DSWshot_small.png

Introduction

I've been using the excellent VS2003 add-in called DataSet QuickWatch by Mohammed Barqawi, and also its enhanced version by Fahad Khalil, for a long time now. Visual Studio 2005 has Visualizers, but the default one for DataSets is too simplistic. So inspired by DataSet QuickWatch, I decided to create an advanced Visualizer for large DataSets.

The Code

One of the greatest features of Visual Studio 2005 is Visualizers. These are viewers for examining the values of complex type variables at runtime. The procedure I followed for creating a Visualizer was as follows:

Create the Visualizer

Create a project of type "Class Library". Rename your .cs file / class to your desired name.

Add a reference to Microsoft.VisualStudio.DebuggerVisualizers.dll and add the corresponding using clause to your class.

using Microsoft.VisualStudio.DebuggerVisualizers;

Inherit your class from DialogDebuggerVisualizer.

class DataSetWatch : DialogDebuggerVisualizer 
{
    ...
    ...

Override the Show method of the base class in your class. Intellisense helps here because when you type protected override and select Show, it automatically generates a signature of the function, saving you from some hand coding.

protected override void Show(IDialogVisualizerService windowService, 
          IVisualizerObjectProvider objectProvider)
{ 
    ...
    ...

Now, we need to tell Visual Studio what Types our visualizer will handle, this will be done with the following assembly attribute in AssemblyInfo.cs:

[assembly: System.Diagnostics.DebuggerVisualizer( 
   typeof(DataSetWatch.DataSetWatch), 
   typeof(VisualizerObjectSource), 
   Target = typeof( System.Data.DataSet), 
   Description = "DataSet Watch")]

Now that our class library has been setup, we can start writing code to get data from the debugger.

protected override void Show(IDialogVisualizerService 
        windowService, IVisualizerObjectProvider objectProvider)
{ 
   DataSet ds = (DataSet)objectProvider.GetObject();
   ...
   ...

After the DataSet Watch dialog has been closed, the original DataSet held by the debugger must be updated with changes made by DSWatch.

if ( objectProvider.IsObjectReplaceable) { objectProvider.ReplaceObject(ds); }

Create a Debugging Host

The Visualizer is now ready to use, and can be dropped into the My Documents\Visual Studio 2005\Visualizers directory. But during development, we need to debug it. This is not possible in the curent circumstances. First, we add a temporary hook to the Visualizer for debugging purposes. We add the following function to the DataSetVisualizer class:

public static void TestShowVisualizer(object objectToVisualize)
{
    VisualizerDevelopmentHost myHost = new 
          VisualizerDevelopmentHost(objectToVisualize, typeof(DataSetWatch)); 
    myHost.ShowVisualizer(); 
}

So in order to overcome this debugging limitation, we add another Console Application type project into the solution that will act as a host for debugging the Visualizer.

Add a reference to the DataSetWatch project and to the Microsoft.VisualStudio.DebuggerVisualizers.dll.

At the point in your code where you want to inspect a test DataSet, add the following call:

 DataSetWatch.DSWVisualizer.TestShowVisualizer(ds);

This will launch the DataSet Watch window and allow you to debug its code.

... and that's pretty much it. Rest of the code is generic WinForms stuff, and isn't really worth discussing.

Features

DataSet Watch 2.0 provides the following enhancements over the classic add-in:

  • Dynamically resizing controls and window (yay).
  • Full-screen grid popup for viewing very large DataSets.
  • XML schema viewing support.
  • Ability to add, rename, and remove tables to/from DataSet.
  • Ability to hide selected tables in case there are many tables in the DataSet.
  • Ability to add, rename, and remove columns to/from tables.
  • Ability to hide selected columns in case of tables with large number of columns.
  • Changes made to DataSet in DataSet Watch are reflected in the original DataSet.
  • Easy deployment, simply drop the DLL into My Documents\Visual Studio 2005\Visualizers.
  • Row filtering.
  • Typed DataSet support.
  • DataTable support.
  • RowState viewing support.
  • Table relation create/edit/delete support (planned).
  • DataTable snapshots allowing you to save a snapshot of a table for future reference (planned).
  • Diff/Compare support for comparing a table with previous snapshots (planned).
  • ... others (as suggestions come in).

History

  • [15-11-2006] Build 4 is here !
    • Added TypedDataSet support.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Osama Abbas


Member
Currently working at NetSol Technologies, Team inBanking
[www.netsolpk.com]
Occupation: Web Developer
Location: Pakistan Pakistan

Other popular Database articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 34 (Total in Forum: 34) (Refresh)FirstPrevNext
GeneralGreat tool but some errors PinmemberMCSDvikasmisra22:24 2 Apr '08  
GeneralThanks! Pinmemberfelix.reychman@agero.se21:56 15 Aug '07  
GeneralRe: Thanks! PinmemberOsama Abbas4:47 16 Aug '07  
GeneralRe: Thanks! Pinmemberfadee3:22 25 Aug '07  
QuestionObject not set to in instance of an object Pinmember9:28 12 Feb '07  
AnswerRe: Object not set to in instance of an object PinmemberOsama Abbas18:33 12 Feb '07  
GeneralRe: Object not set to in instance of an object PinmemberJLibertor8:12 13 Feb '07  
QuestionLost changes Pinmemberpgago7:05 12 Feb '07  
AnswerRe: Lost changes PinmemberOsama Abbas18:28 12 Feb '07  
GeneralSerialization error Pinmember12:01 9 Jan '07  
GeneralRe: Serialization error PinmemberOsama Abbas19:21 9 Jan '07  
GeneralInstallation? PinmemberUrs Enzler21:39 3 Jan '07  
GeneralRe: Installation? PinmemberOsama Abbas21:55 3 Jan '07  
GeneralRe: Installation? PinmemberUrs Enzler22:58 3 Jan '07  
GeneralRe: Installation? PinmemberOsama Abbas23:16 3 Jan '07  
GeneralRe: Installation? PinmemberUrs Enzler23:24 3 Jan '07  
Generalexcellent, but a few suggestions [modified] Pinmembersyzygyfire5:17 28 Dec '06  
GeneralRe: excellent, but a few suggestions PinmemberOsama Abbas21:11 28 Dec '06  
GeneralRe: excellent, but a few suggestions Pinmembersyzygyfire0:08 2 Jan '07  
GeneralRe: excellent, but a few suggestions Pinmembersyzygyfire0:39 2 Jan '07  
GeneralRe: excellent, but a few suggestions PinmemberOsama Abbas19:45 2 Jan '07  
GeneralRe: excellent, but a few suggestions PinmemberJohn Mills9:48 2 Jan '07  
Questionhow about adding copy+paste to grid? PinmemberDieg2:22 26 Dec '06  
AnswerRe: how about adding copy+paste to grid? PinmemberOsama Abbas18:03 27 Dec '06  
Question"Typed DataSet support (planned)" - when ?? Pinmembermarcin.rawicki1:35 2 Nov '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 29 Dec 2006
Editor: Smitha Vijayan
Copyright 2006 by Osama Abbas
Everything else Copyright © CodeProject, 1999-2009
Web19 | Advertise on the Code Project