Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
How to stop FOREACH loop without breaking out of the loop
Abraham Olatubosun
Jul 17 2017 12:20 PM
233
Reply
Dear friends,
Best of the day, i will apreciate any solution from you,
i am writting a program that loop through set of records in a database
this database contain duplicate records to loop through the records i am
fist use a sql statement to pass the records to a datatable
Select
Distinct
*
from
tbl_PatientsTable
i then use the following statement to loop through the record, where i find thesame record ID coming back it should skip it and take the next record it that way i will not display duplicates,
var PatientIDs =
""
;
DT1 = ConnectAll.LastDrugPickup(TextBox1.Text.Trim(), TextBox2.Text.Trim());
foreach
(DataRow r
in
DT1.Rows)
{
if
(PatientIDs == r[
"PatientID"
].ToString().Trim()) {
break
; }
do
other things ......
}
But my problem is break command make the loop to happend only once.
please how can i resolve this without using break and be able to fetch my records with no duplicates, since DISTINCT could not help.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
find the item in a list of lists. I am struggling
What is the best to use between xamarin OR java?