foreach (DataRow dr in ds.Tables[0].Rows)
{
try
{
DotheNeedFull();
}
catch (Exception ex)
{
//ex.Message();
}
}
//Sorry, I had a misplaced a bracket in the last message
Main Topics
Browse All TopicsDear Experts,
In my ASP.net page which is in C#.net I am using Try catch like this
How do I change in such a way that if it fails in the DotheNeedFull(); it should continue instead of breaking. Currently whats happening is that if there are 100 records and its going on the loop if at 20th records DotheNeedfull fails its breaking and not continue the for loop
try
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
DotheNeedFull();
}
}
catch (Exception ex)
{
//ex.Message();
}
public void DoTheNeedFull()
{
try
{
CreateRecords();
}
catch (Exception ex)
{
//ex.Message();
}
}
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
as ur code also has the exception handled in the DoTheNeedful function, if there is an error it would have gone into the exception block and then returned back to the parent function and continued .. so you say its breaking over there and coming out of the loop .. so how have u handled the function in the DoTheNeedful function and what happens in the parent function? we need to see some code ..
Rejo
Business Accounts
Answer for Membership
by: hpdvs2Posted on 2007-01-12 at 10:01:05ID: 18303497
You need to put the try catch inside the Foreach statement.
foreach (DataRow dr in ds.Tables[0].Rows)
{try
{
DotheNeedFull();
}
}
catch (Exception ex)
{
//ex.Message();
}
this way the error gets checked per line. If you don't trust that .Rows will be anything, then just put an extra try catch inside of it.
you can nest try-catch statements.