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

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

问题描述

我刚刚开始使用 ADO.NET 以及 DataSets 和 DataTables.我遇到的一个问题是,在尝试调试时似乎很难分辨数据表中的值.

有哪些最简单的方法可以快速查看 DataTable 中保存了哪些值?是否有办法在调试时查看 Visual Studio 中的内容,或者是将数据写入文件的唯一选择?

我创建了一个小实用程序函数,可以将 DataTable 写入 CSV 文件.然而,生成的 CSV 文件被切断了.在写出 System.Guid 的过程中应该是最后一行的大约 3 行,文件就停止了.我不知道这是我的 CSV 转换方法的问题,还是 DataTable 的原始人口问题.

更新

忘记我刚刚忘记刷新流写入器的最后一部分.

解决方案

设置断点后,在填充 DataTable 或 DataSet 后,如果将鼠标悬停在变量上,则可以看到放大镜.如果单击它,它将弹出 DataTable Visualizer,您可以在 ):

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.

DataTable Visualizer (image credit):

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

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