Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Simple question about ending loops

Simple question about ending loops

Scheduled Pinned Locked Moved C#
questiondatabasedebuggingjsonhelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    falles01
    wrote on last edited by
    #1

    I have a problem where I've got a large amount of nested if statements. they were all working and executing the correct numbe of times until I added some loops at the start. The debugger is showing that it executes the first section and then starts again without going to the next condition. I know I have to change the condition maybe. This is the first section that gets executed continuously. Obviously there will always be rows, but the rest of conditions say, if checkedbox is ticked, or combobox is selected bla bla, so I can't see why (if I select a combobox item and click search, it is not executing). Is there a way of telling the code that you want to end the loop after all the entries in the database have been covered? Make sense? foreach (DataRow row in dsapps.Tables[0].Rows) { if (row["EmployeeID"].ToString().Equals(EmployeeID.ToString()) == false) { if (EmployeeID > 0)

    M 1 Reply Last reply
    0
    • F falles01

      I have a problem where I've got a large amount of nested if statements. they were all working and executing the correct numbe of times until I added some loops at the start. The debugger is showing that it executes the first section and then starts again without going to the next condition. I know I have to change the condition maybe. This is the first section that gets executed continuously. Obviously there will always be rows, but the rest of conditions say, if checkedbox is ticked, or combobox is selected bla bla, so I can't see why (if I select a combobox item and click search, it is not executing). Is there a way of telling the code that you want to end the loop after all the entries in the database have been covered? Make sense? foreach (DataRow row in dsapps.Tables[0].Rows) { if (row["EmployeeID"].ToString().Equals(EmployeeID.ToString()) == false) { if (EmployeeID > 0)

      M Offline
      M Offline
      martin_hughes
      wrote on last edited by
      #2

      Missing a curly brace somewhere? How about an errant ";"?

      "On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't. "I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it." -Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.

      F 1 Reply Last reply
      0
      • M martin_hughes

        Missing a curly brace somewhere? How about an errant ";"?

        "On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't. "I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it." -Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.

        F Offline
        F Offline
        falles01
        wrote on last edited by
        #3

        Thanks yes I worked it out. It was just a silly curly brace. i wasn't missing one as such, I just had to move them around. Wasn't worth the question. Sorry about that.

        C M 2 Replies Last reply
        0
        • F falles01

          Thanks yes I worked it out. It was just a silly curly brace. i wasn't missing one as such, I just had to move them around. Wasn't worth the question. Sorry about that.

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          falles01 wrote:

          It was just a silly curly brace. i wasn't missing one as such, I just had to move them around. Wasn't worth the question. Sorry about that.

          Don't worry about it. There has been many a time I've sat in front of a compiler in despair at the apparently cryptic error message only to discover after I've asked someone else to have a look they spotted in seconds the missing semi-colon or some such trivial detail.


          Upcoming FREE developer events: * Developer Day Scotland My website

          1 Reply Last reply
          0
          • F falles01

            Thanks yes I worked it out. It was just a silly curly brace. i wasn't missing one as such, I just had to move them around. Wasn't worth the question. Sorry about that.

            M Offline
            M Offline
            martin_hughes
            wrote on last edited by
            #5

            As Colin says - easy mistake to make.

            "On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't. "I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it." -Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups