October 9th, 2012, 08:16 AM
[RESOLVED] Form1_Load problems
hey, im having a slight problem with this, i know form1_load happens before the form is shown, so im trying to use that to my advanage, dunno if its the correct way to go about it but ill explain and hopefully get some tips.
when my app is loaded, i want it to check to see if the db is online, if false it throws exception, if true, uses next bit of code.
if true, i want it to see if the computer id is saved in the db, if true, goes to next check if exception, adds time stamp etc to db.
only thing is,
when the first exception is thrown and the db does not connect, the code keeps running instead of waiting, how do i do this so that if there is a connection error it stops the code from continuing.
i have at the moment
private void Form1_Load(object sender, EventArgs e)
//Database Connection on Application Run
string connection = @"Data Source=blah blah blah";
SqlConnection cn = new SqlConnection(connection);
//following tests to make sure database connection is active if not shows
//error on DatabaseError form
//check db if computer id is added
//add if false and add start date and end date open form2
//true, check if registered
//if false check dates are in time if not close open form 3
//if true check if activated by purchace, if true add times open form 4
//if false pop up reminder to activate open form 5
thanks in advance
Last edited by VirUs1234; October 9th, 2012 at 08:54 AM.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!