Results 1 to 2 of 2

Thread: [RESOLVED] Form_Load not firing

  1. #1

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Resolved [RESOLVED] Form_Load not firing

    I am bringing a VB6 app to C# 2008. It is a pretty simple app, that it why I chose it. It only has 3 forms. Going back and forth between the screens works fine. I am trying to process some database code on the form_load event of one of the forms. I stepped through it ans the form_Load does not fire. I changed the name to form_Activate. That does not fire either.

    This is the code from the sending screen (I am going to frmLog).

    Code:
    namespace Time_Clock
    {
        public partial class frmSystem : Form
        {
            public frmSystem()
            {
                InitializeComponent();
            }
    
            private void btnExit_Click(object sender, EventArgs e)
            {
                Application.Exit();
            }
    
            private void btnIO_Click(object sender, EventArgs e)
            {
                this.Hide();
    
                frmMain main = new frmMain();
                main.Show();
            }
    
            private void btnStatus_Click(object sender, EventArgs e)
            {
                this.Hide();
    
                frmLog log = new frmLog();
                log.Show();
            }
        }
    }
    This is the code on the receiving form (I am only including the form loading stuff)
    Code:
    namespace Time_Clock
    {
        public partial class frmLog : Form
        {
            public frmLog()
            {
                InitializeComponent();
            }
            public void FrmLog_Activated(object sender, EventArgs e)
            {
                SqlDataReader rdr = null;
    
                SqlConnection conn = new SqlConnection("Data Source=PRIMERO;Initial Catalog=Techni;Persist Security Info=True;User ID=sa;Password=pacjo");
    
                SqlCommand sqlEmp = conn.CreateCommand();
    
                sqlEmp.CommandText = "SELECT * FROM Empfile ORDER BY Empnum";
    
                // open the connection
                conn.Open();
                MessageBox.Show("database open");
    
                // get an instance of the SqlDataReader
                rdr = sqlEmp.ExecuteReader();
                while (rdr.Read())
                {
                    string employee = (string)rdr["EMPNUM"];
    
                    TS1.Text = (employee);
                    
                }
                // close the reader and connection
                rdr.Close();
                conn.Close();
            }
    Why does this code not fire at all? In VB it would be quite simple. I'm sure it is simple here, as well.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

  2. #2

    Thread Starter
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Form_Load not firing

    I've got this bit working now. I had to delete the form_load event and recreate it.
    ===================================================
    If your question has been answered, mark the thread as [RESOLVED]

Posting Permissions

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



Click Here to Expand Forum to Full Width