Code help?

Nov. 25th, 2008 02:11 am
aethwolf: (Me)
[personal profile] aethwolf
Anyone who knows C# wanna help a wolf out?



        public void refreshStudentList()
        {
            // Student attribute containers
            int iID;
            string strFirstName;
            string strLastName;
            string strEmail;
            int intTeamID;
            Student s = new Student();
            
            // Delete the old student list
            //m_alStudentList.Clear();

            // Connect to the database
            connect();

            // Query the database for the list of students
            m_comCommand.CommandText = "select * from STUDENT where TEAM_ID = " + ApplicationController.m_tmSelectedTeam.getID();
            OleDbDataReader rdrReader = m_comCommand.ExecuteReader();

            // Fill the student list with the data from the database
            while (rdrReader.Read())
            {
                // Get/convert course attributes
                iID = rdrReader.GetInt32(0);
                strFirstName = rdrReader.GetString(1);
                strLastName = rdrReader.GetString(2);
                strEmail = rdrReader.GetString(3);
                intTeamID = rdrReader.GetInt32(4);

                s.initialize(iID, strFirstName, strLastName, strEmail, intTeamID);
                
                // Add the course to the list
                m_alStudentList.Add(s);
            }

            // Close the reader object
            rdrReader.Close();

            // Disconnect from the database
            disconnect();
        }



What all of that is supposed to do is query the DB, and then loop through all the data pulled from the DB building Student objects and inserting them into the m_alStudentList ArrayList. I've got functional code almost identical to this about 10 lines up, so I can't figure out where in the Hell I'm screwing up.

Profile

aethwolf: (Default)
Steamworks

December 2022

S M T W T F S
    123
456 78910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 28th, 2025 01:04 am
Powered by Dreamwidth Studios