TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abraham Olatubosun
NA
471
113.3k
How to stop FOREACH loop without breaking out of the loop
Jul 17 2017 12:20 PM
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.
Reply
Answers (
1
)
find the item in a list of lists. I am struggling
What is the best to use between xamarin OR java?