调试时如何查看DataTable [英] How to view a DataTable while debugging

查看:259
本文介绍了调试时如何查看DataTable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用ADO.NET和DataSet以及DataTables。我遇到的一个问题是,尝试调试时,很难说出数据表中的值。



快速查看最简单的方法是什么?在DataTable中保存了哪些值?有没有什么可以在调试过程中看到Visual Studio中的内容,还是将数据写入文件的唯一选择?



我创建了一个小功能,会将DataTable写入CSV文件。然而,生成的CSV文件已被切断。从写入System.Guid文件的中间最后一行应该是最近的3行。我无法确定这是CSV转换方法的问题,还是DataTable的原始数据。



更新



忘记最后一部分我只是忘了冲洗我的流写入器。

解决方案

设置断点后,在填充DataTable或DataSet后,如果将鼠标悬停在变量上,则可以看到放大镜。如果您点击它,它将显示DataTable Visualizer,您可以阅读有关 here



在下面的图片中,dt是我的DataTable变量,断点被打下几行,允许我将鼠标悬停在该值上。使用Visual Studio 2008。



alt text http:/ /i25.tinypic.com/2vvkf0x.png



DataTable Visualizer image credit ):


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.

解决方案

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 http://i25.tinypic.com/2vvkf0x.png

DataTable Visualizer (image credit):

这篇关于调试时如何查看DataTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆