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
Olaide Azeez
1.7k
67
12.9k
Looping taking too long to execute
Apr 27 2017 9:29 AM
Please find part of my code below, but it seems the looping part of it is taking too much time to execute, how can I improve the speed.
string gss = "select sn,hcpcode from capitation";
SqlCommand cgg = new SqlCommand(gss, gap);
reader = cgg.ExecuteReader();
while (reader.Read())
{
ar.Add(reader["sn"].ToString());
arHosp.Add(reader["hcpcode"].ToString());
}
reader.Close();
for (int x = 0; x < ar. count; x++)
{
string sss = "update capitation set surname = null where surname like '%Page%' or surname like '%healthcare%' ";
SqlCommand ccc = new SqlCommand(sss, gap);
ccc.ExecuteNonQuery();
string kss = "update capitation set hcpcode = (select oldnhisno from capitation where oldnhisno like '%/%' and sn = @hs) where sn = @ssn";
SqlCommand ckk = new SqlCommand(kss, gap);
ckk.Parameters.AddWithValue("@hs", ar[x].ToString());
ckk.Parameters.AddWithValue("@ssn", ar[x].ToString());
ckk.ExecuteNonQuery();
}
Reply
Answers (
1
)
connection string issue
need help on the submit button