PC Review


Reply
Thread Tools Rate Thread

How can I see what's in a collection during debugging?

 
 
pantichd
Guest
Posts: n/a
 
      8th Nov 2004
<I also posted this on microsoft.public.vsnet.debugging 'cuz I didn't know
which was more appropriate or would get quickest response>


Hello,

Can someone tell me how I can view the contents of a collection when in
debug mode?

For example, I working with a dataset and when the app stops at a breakpoint
I'd like to see what is actually in the Tables collection of the dataset. I
add a watch on my dataset variable and expand the Tables object. It just
keeps showing me the following: Count, IsReadOnly, Is Synchronized, Item and
SyncRoot. Expand SyncRoot and you're at the beginning of a big old
recursion.

So if I want to see what's in row x of table y for example, I have to create
a variable in my code representing that row in that table and add a watch
for THAT variable. I have to believe that there is an easier, more dynamic,
way for me to inspect the content of this during debugging.

Any help would be greatly appreciated.

David.



 
Reply With Quote
 
 
 
 
Peter Rilling
Guest
Posts: n/a
 
      8th Nov 2004
Remember, collections are not the items themselves, they contain the items.
The Item property is actually what contains the values. Now, the debugger
is not good at listing items in the Item property so what you may have to do
is use an indexer to get at the data (assuming you are using C#). For
example, you would have to do myTbl[0] to see the properties, from there you
can access the rows, and so on.


"pantichd" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> <I also posted this on microsoft.public.vsnet.debugging 'cuz I didn't know
> which was more appropriate or would get quickest response>
>
>
> Hello,
>
> Can someone tell me how I can view the contents of a collection when in
> debug mode?
>
> For example, I working with a dataset and when the app stops at a

breakpoint
> I'd like to see what is actually in the Tables collection of the dataset.

I
> add a watch on my dataset variable and expand the Tables object. It just
> keeps showing me the following: Count, IsReadOnly, Is Synchronized, Item

and
> SyncRoot. Expand SyncRoot and you're at the beginning of a big old
> recursion.
>
> So if I want to see what's in row x of table y for example, I have to

create
> a variable in my code representing that row in that table and add a watch
> for THAT variable. I have to believe that there is an easier, more

dynamic,
> way for me to inspect the content of this during debugging.
>
> Any help would be greatly appreciated.
>
> David.
>
>
>



 
Reply With Quote
 
pantichd
Guest
Posts: n/a
 
      8th Nov 2004
Peter,

First of all, thanks for responding.

I'm fairly new to .net (been doing Java for awhile) but I think I have a
pretty good handle on what collections are. : )

The situation I'm describing is something I've been able to do in other
tools.

It sounds like you're telling me that I really DO need to create a local
variable in my code to represent a specific table in the Tables collection
of a dataset.

I tried that and when I do a watch on that in the debugger I see that there
is an item called rows and another called rowCollection. When I expand those
I get in the recursion again.

The more I look at this the more I think I'm gonna have to define a local
variable to represent a specific row in a specific table. That seems very
inefficient. Please tell me there is a better way!

Thanks!

PS- I'm using VisualBasic.net

"Peter Rilling" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Remember, collections are not the items themselves, they contain the

items.
> The Item property is actually what contains the values. Now, the debugger
> is not good at listing items in the Item property so what you may have to

do
> is use an indexer to get at the data (assuming you are using C#). For
> example, you would have to do myTbl[0] to see the properties, from there

you
> can access the rows, and so on.
>
>



 
Reply With Quote
 
=?Utf-8?B?S2Fs?=
Guest
Posts: n/a
 
      8th Nov 2004
If you drill down into the dataset you will find tables. Drill down into it
and you will find columns and rows. Each of these has an items that you can
look at.
Kal

"pantichd" wrote:

> Peter,
>
> First of all, thanks for responding.
>
> I'm fairly new to .net (been doing Java for awhile) but I think I have a
> pretty good handle on what collections are. : )
>
> The situation I'm describing is something I've been able to do in other
> tools.
>
> It sounds like you're telling me that I really DO need to create a local
> variable in my code to represent a specific table in the Tables collection
> of a dataset.
>
> I tried that and when I do a watch on that in the debugger I see that there
> is an item called rows and another called rowCollection. When I expand those
> I get in the recursion again.
>
> The more I look at this the more I think I'm gonna have to define a local
> variable to represent a specific row in a specific table. That seems very
> inefficient. Please tell me there is a better way!
>
> Thanks!
>
> PS- I'm using VisualBasic.net
>
> "Peter Rilling" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Remember, collections are not the items themselves, they contain the

> items.
> > The Item property is actually what contains the values. Now, the debugger
> > is not good at listing items in the Item property so what you may have to

> do
> > is use an indexer to get at the data (assuming you are using C#). For
> > example, you would have to do myTbl[0] to see the properties, from there

> you
> > can access the rows, and so on.
> >
> >

>
>
>

 
Reply With Quote
 
Pedja
Guest
Posts: n/a
 
      9th Nov 2004
>
> Hello,
>
> Can someone tell me how I can view the contents of a collection when in
> debug mode?
>


Hi David.

I usually use Command Window for that purpose. It is accessible when
the application is stopped (let's say after it hit the breakpoint).
You can type something like:

?myDataset.Tables(1).Rows(5).ItemArray

or

?myDataset.Tables(1).Rows(5)("ColumnName")

You can also use the Watch Window. Declare the watch variable as:

myDataset.Tables(1).Rows(5).ItemArray

I prefer Command Window since you'll have the help of IntelliSense
there.

Hope this helps.
- Pedja.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Debugging code being run during garbage collection? Brian Microsoft C# .NET 9 15th Apr 2008 04:04 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft Dot NET 1 18th May 2007 10:24 AM
viewing whole collection while debugging Madhur Microsoft Dot NET 3 23rd Jul 2006 11:36 PM
Re: Debugging Garbage Collection Shri Borde Microsoft Dot NET Framework 0 19th Jul 2003 02:32 AM
Re: Debugging Garbage Collection Pavel Lebedinsky Microsoft Dot NET Framework 0 17th Jul 2003 04:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:21 AM.