[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

c# stop running

Posted on 2011-10-23
4
Medium Priority
?
183 Views
Last Modified: 2012-05-12
How can i make a condition in c#

if (count < 10)

then stop running program
using (MySqlCommand cmd = new MySqlCommand("SELECT COUNT( * ) FROM  `member`  WHERE  `tambol` LIKE  '¿¿¿¿¿¿¿' ", conDatabase))
                {
                    try
                    {


                        long count = (long)cmd.ExecuteScalar();
                    

                        Console.WriteLine(count.ToString());

                        if (count < 10)
                        {
                            exit ;
                        }

                    }
                    catch (MySqlException ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }

Open in new window

0
Comment
Question by:teera
4 Comments
 
LVL 17

Assisted Solution

by:sonawanekiran
sonawanekiran earned 200 total points
ID: 37016097
Try return; instead of exit;
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 200 total points
ID: 37016116
Try break; instead of exit;

 if (count < 10)
                        {
                           break;
                        }

0
 
LVL 45

Assisted Solution

by:AndyAinscow
AndyAinscow earned 200 total points
ID: 37016141
use  
          Application.Exit();
instead of exit;
0
 
LVL 9

Accepted Solution

by:
sachinpatil10d earned 800 total points
ID: 37016148
break;                        //The break statement terminates the closest enclosing loop
return;                       //will exit the current method
Application.Exit();       //exit the application use
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Screencast - Getting to Know the Pipeline
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question