Sorting the Recordset

Note   You add no new code to Enroll in this topic.

The procedure for sorting a recordset is very simple: set the member variable CRecordset::m_strSort before calling CRecordset::Open. The syntax for m_strSort is exactly that of the SQL ORDER BY clause, which is one or more columns separated by commas.

Suggested Reading

  • , Microsoft Foundation Class Reference

  • , Visual C++ Programmer’s Guide

  • , Visual C++ User’s Guide

  • , Visual C++ Programmer’s Guide

The CCourseSet records are all sorted by CourseID (which you have already added):

pDoc->m_courseSet.m_strSort = "CourseID";

Also, the CSectionSet records for a given course name are sorted by class section:

m_pSet->m_strSort = "SectionNo";