ASP.NET DataReader值 [英] ASP.NET DataReader values

查看:40
本文介绍了ASP.NET DataReader值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Visual Studio中查看DataReader内部的值.请注意,调试时我指的是监视窗口.例如,如果数据读取器中有两个字段,即ID和Name,是否可以查看这些值?当我将鼠标悬停在DataReader上方时,它只是告诉我它是什么类型的对象,即DataReader.

Is there a way of viewing the values inside a DataReader in Visual Studio. Please note that I am referring the watch window when debugging. For example, if there are two fields inside the datareader i.e. ID and Name, is there a way to view the values? When I hover above the DataReader, it just tells me what type of object it is i.e. a datareader.

推荐答案

您可以在 reader 中查看列和数据,如下所示:

You can view both columns and data in the reader as below:

要查看列:快速浏览阅读器>结果视图>[0], 1 ... [展开任何索引]>非公共成员>_schemainfo>[0], 1 ... [展开任何索引],这将向您显示列名称和数据类型.

To view columns: Quick watch to the reader > Result View > [0], 1...[expand any index] > Non-Public members > _schemainfo > [0], 1...[expand any index], this will show you column name and data type.

要查看数据:快速阅读阅读器>结果视图>[0], 1 ... [展开任何索引]>非公共成员>_values>[0], 1 ... [展开任何索引],这将向您显示列中显示的数据.

To view data: Quick watch to the reader > Result View > [0], 1...[expand any index] > Non-Public members > _values > [0], 1...[expand any index], this will show you data present at the columns.

修改:列信息视图

列的数据视图

更新:数据也可以通过以下方式查看:

Update: data also can see as below way:

if (reader.HasRows)
{
    while (reader.Read())
    {
        int Id = Convert.ToInt32(reader["ID"]);
        string Name = Convert.ToString(reader["Name"]);
    }
}

谢谢

这篇关于ASP.NET DataReader值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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