Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 608
  • Last Modified:

Help with CDaoRecordset::m_strSort !!!!

I need to know how I use the CDaoRecordset::m_strSort member...... My MFC help its not working!!!! (MSDN)
How I my options ??? alphabetical order??, what else ????
after I set m_strSort what should I do??? call Requery???
thanks in advance!!!
0
matias103098
Asked:
matias103098
1 Solution
 
plarocheCommented:
Here's a doc excerpt that explains it very clearly. If you need more details just ask.


To specify a sort order for a recordset object

Construct a new recordset object (or prepare to call Requery for an existing one).


Set the value of the object’s m_strSort data member.
The sort is a null-terminated string. It contains the contents of the ORDER BY clause but not the keyword ORDER BY. For example, use:

recordset.m_strSort = "LastName DESC, FirstName DESC";

not

recordset.m_strSort = "ORDER BY LastName DESC, FirstName DESC";

Set any other options you need, such as a filter, locking mode, or parameters.


Call Open for the new object (or Requery for an existing object).
The selected records are ordered as specified. For example, to sort a set of student records in descending order by last name, then first name, do the following:

// Construct the recordset
CStudentSet rsStudent( NULL );
// Set the sort
rsStudent.m_strSort = "LastName DESC, FirstName DESC";
// Run the query with the sort in place
rsStudent.Open( );

The recordset contains all of the student records, sorted in descending order (Z to A) by last name, then by first name.


0
 
matias103098Author Commented:
thanks!!! your help was very usefull!!!! :)
but please, you show me the DESC keyword.... I figure that exist ASC too....
but... exisist other keywords????
thanks in advance
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now