473,378 Members | 1,383 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Exiting program

Hi folks,

I have a simple form like this:

public class Blah: System.Windows.Forms.Form{
private OleDBConnection conn;
public class Blah(){
conn.ConnectionString = "... ....";
try{
conn.open();
}
catch(Exception e){
Application.Exit(); <--- does not work
}
}

static void Main(){
Application.run(new Blar());
}
}

Problem:
1. When system fails to connection to SQL server, it catchs error and
executes Application.Exit(). But it does not work! After this line, it still
pops up the form.

Question:
1. How to terminate program properly when something goes wrong during system
loading?

Thanks,

Karl
Nov 16 '05 #1
1 2733
Calling Application.Exit only sends a message that it wants to shutdown, but
you must exit the procedure before it will actually shutdown. Just type
return; so that it exits the procedure after the Application.Exit

"Karl" wrote:
Hi folks,

I have a simple form like this:

public class Blah: System.Windows.Forms.Form{
private OleDBConnection conn;
public class Blah(){
conn.ConnectionString = "... ....";
try{
conn.open();
}
catch(Exception e){
Application.Exit(); <--- does not work
}
}

static void Main(){
Application.run(new Blar());
}
}

Problem:
1. When system fails to connection to SQL server, it catchs error and
executes Application.Exit(). But it does not work! After this line, it still
pops up the form.

Question:
1. How to terminate program properly when something goes wrong during system
loading?

Thanks,

Karl

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matthew Thorley | last post by:
I wrote a simple python program that scrapes a web page every 30 secons and dumps the result in a data base. I want to use my linux distros build in init tools to run the script in the back ground...
2
by: Will | last post by:
I have this bit of code: #!/usr/bin/python import subprocess calc = subprocess.Popen("dc", stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) max = 5
39
by: vineoff | last post by:
If I'm having nested loops like: for (...) for (..) for (...) { /* exit here */ } and I need to exit from there ^ . Is it better to use exceptions or goto or some other method?
1
by: Abby | last post by:
I'm writing a code to send/receive udp packet. I'll receive ip address from user (this is the starting ip), then I'll ask user how many ip he wants to connect to. For examples: Please enter 1st...
22
by: L. Westmeier | last post by:
Is there a way to have to exiting point in a void function? I don't want to exit the program but just this function. Any answers appreciated. L. Westmeier
8
by: Maloney | last post by:
Exit thread in C#CF. I'm createing a thread and setting a class object for when to exit. Before creating the thread i check if the thread is running, if so set the flag to exit the thread. ...
2
by: pnp | last post by:
Hi all, I'm working on a win app that uses a logon form to verify the user that logs in the program and then hides the first form and displays an MDI form where the user does his work. The app is...
1
by: pp4175 | last post by:
Hello Everyone, I am currently working on writing a GUI wrapper for a Menu driven DOS Program. What I was looking on doing is redirecting stdout/stdin to a stream and read/write similar to a...
6
by: John (Z R) L | last post by:
Hi all, I am very new to programming, and I chose to study the Python language before C++. I am currently using the Wikibooks "Non-Programmer's Tutorial for Python", and am up to the section "Who...
7
by: tsmithcs | last post by:
I'm using Visual C++ 6.0 on Windows 2000/XP machines. I can't run this program in release mode because the libraries/dll are not compatiable with release mode. I've looked for new ones and can't...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.