[RESOLVED] Form1_Load problems
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: [RESOLVED] Form1_Load problems

Threaded View

  1. #1
    Join Date
    Sep 2012
    Posts
    14

    [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
    try
    {
    cn.Open();
    }
    catch (Exception)
    {
    new DatabaseError().Show();

    }
    //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

    Dean
    Last edited by VirUs1234; October 9th, 2012 at 08:54 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center