Simple question about ending loops
-
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)
-
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)
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.
-
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.
-
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.
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
-
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.
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.