Make DbDataReader start reading again from the beginning of the result set

How to make dr.Read(); start reading again from the beginning if a condition is satisfied?

Something like:

SqlDataReader dr = command.ExecuteReader();
for(int i=0; dr.Read() ; i++){
    if(condition ){
        //let dr.Read() start reading from the beginning


You can't.

The *DataReader classes are forward-only iterators.

Instead, you can store the results in a List<T> (or a DataTable)

The only way to restart it is to grab a new reader with ExecuteReader().

You can do that by first closing the datareader using dr.close(); then initializing it again.


Where command is the MySqlCommand object.

Need Your Help

Swift - UITableView set separator style

ios uitableview swift

How do i set the Separator Style of my UITableView in Swift? I want to get rid of the separator so that there is no grey line between the cells in my table view. Any suggestions would be greatly

Web API in MVC Project isn't hitting breakpoints ("symbols not loaded") debugging

I have an ASP.NET MVC project, with an ASP.NET web api defined as an area in this project. So the structure is the following: