Share via


Creating a Recordset for the Course Table

Enroll currently has one recordset, for the Section table. This recordset fills the controls on the CSectionForm record view with information about a single class section of the currently selected course name. Now you will add a second recordset, for the Course table, used to fill the combo box control with a list of all available course names.

Suggested Reading in the Visual C++ Programmer’s Guide

To create a new recordset class

  1. From the View menu, click ClassWizard.

  2. Click Add Class, and from the menu, click New.

    This opens the New Class dialog box.

  3. Under Class information, in the Name box, type CCourseSet.

  4. From the Base class drop list, select CRecordset.

  5. Click OK.

    This opens the Database Options dialog box.

To connect the recordset class to the Course table

  1. From the ODBC drop list, select Student Registration, and click OK.

    Depending on the database type, you may need to supply additional information to log in to the data source.

    The Select Database Tables dialog box opens.

  2. Select the table name Course, and click OK. Depending on the data source type you are using, additional qualifiers may precede or follow the table name.

    This connects the table name to class CCourseSet and returns you to the ClassWizard. If necessary, click the Member Variables tab. The Class name box shows CCourseSet, and three names are listed in the Column Names box.

    The table below shows the column names, their data members, and their data types.

  3. Click OK to close ClassWizard.

Note   On the Member Variables tab, you can see that all of the table’s columns are already assigned to field member variable. You can use ClassWizard to delete those variables if you don’t need to access or modify the columns — but be careful not to delete a field member variable for a column that is part of the table’s primary key.

CCourseSet Data Members

Column name Type Data member
CourseID CString
m_CourseID
CourseTitle CString
m_CourseTitle
Hours int
m_Hours