[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

How do to set reader to true ?

I want to set reader to true in the case that no values are returned.
reader is a MySqlDataReder.

I want to do that so that by default it will read through a loop at least 1 time.
How do I do this ? The code below does not work.
if(!reader.Read())
                reader.Read().Equals(true);
            if (!reader1.Read())
                reader1.Read().Equals(true);
            if (!reader2.Read())
                reader2.Read().Equals(true);
            if (!reader3.Read())
                reader3.Read().Equals(true);*/
 
            while (  reader.Read()   )
                while (  reader1.Read()   )
                    while (   reader2.Read()   )
                        while (   reader3.Read()   )
                        {

Open in new window

0
pillmill
Asked:
pillmill
1 Solution
 
williamcampbellCommented:
use do while instead of while




do
{
            if(!reader.Read())
                reader.Read().Equals(true);
            if (!reader1.Read())
                reader1.Read().Equals(true);
            if (!reader2.Read())
                reader2.Read().Equals(true);
            if (!reader3.Read())
                reader3.Read().Equals(true);
 
while ( reader.Read()   && reader1.Read()  && reader2.Read()   && reader3.Read()  );

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now