DataReader Values ​​for ASP.NET

Is there a way to view values ​​inside a DataReader in Visual Studio. Please note that when debugging, I turn to the clock window. For example, if there are two fields inside datareader ie ID and Name, is there a way to view the values? When I hang over the DataReader, it just tells me what type of object it is, for example, datareader.

+4
source share
3 answers

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

To view the columns : quick view for the reader> View results> [0], 1 .. [expand any index]> Non-public participants> _schemainfo> [0], 1 ... [expand any index], this will show the column name and data type.

To view the columns : quick view for the reader> View results> [0], 1 .. [expand any index]> Non-Public members> _values> [0], 1 ... [expand any index], this will show your data in columns.

Edit : Column Information Columnview

View data for columns Dataview

Update: data can also be seen below:

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

thanks

+3
source

You cannot do this because of the nature of the DataReader: it does not store actual data, but simply some kind of "pointer" to the database.

For the Reader to be filled with data, you must call its Read() method - this will fill the object with the values ​​of the next record, if they are available, then return true , otherwise it will return false and the data will not be available.

In the Visual Studio viewport, you can dynamically execute this Read() method - just enter reader.Read() and see the result - then to read the current values, just write reader[0] and reader[1] in the viewer window.

In any case, all this is impossible only from the tooltip, only in a special viewing window.

+3
source

You can enter reader["ID"] and reader["Name"] to view the value in the view window.

+1
source

Source: https://habr.com/ru/post/1385743/


All Articles