Click here to Skip to main content
Licence 
First Posted 7 Sep 2003
Views 67,565
Bookmarked 50 times

Very useful class to display SQL SELECT results

By | 3 Nov 2003 | Article
Very useful class to display SQL SELECT results.

Sample screenshot with CListCtrlEx

Fig1. Illustrates CRecordListCtrl based on CListCtrlEx from this article.

Introduction

In this article, I present a simple CRecordListCtrlM to display the results of a SQL SELECT operation. Why another similar grid control? Yeah, you say, many grids are available for VC++ developers, but this control is small and very useful in MFC applications. Moreover, in combination with CListCtrlEx, presented here.

You will find many advanced unique features for developers and end users. Readers also can replace MFC ODBC classes to MFC DAO. Using ADO or OLE DB classes is also possible.

Sample screenshot with CListCtrl

Fig2. Illustrates CRecordListCtrl based on standard CListCtrl.

In most cases, all that you need to do is call the following:

    // aDSN is ODBC datasource name
    // aSQL is SQL SELECT query
    m_List.LoadListCtrl(CString aDSN, CString aSQL); 

How to Use

Using CRecordListCtrl is very simple.

  1. Include the RecordListCtrlEx.h and RecordListCtrlEx.cpp files in your project.
  2. If you want to use CListCtrlEx in this control instead of CListCtrl, just replace with CListCtrlEx.

Conclusion

By reading this article, you receive two variants for using the CRecordListCtrl control. The first is based on CListCtrl, providing an easy-to-use way to display SQL SELECT query results. The second is based on CListCtrlEx, and also makes an easy way possible to show the results of SQL SELECT and provides a lot of end-user-friendly functionality. The functions are:

  • Multicolumn sorting (working as SQL ORDER BY)
  • Multicolumn filtering (working as an additional WHERE section in SQL SELECT)
  • Column data type auto detection (allows the user input to be more friendly)
  • Column coloring and dragging
  • Storing/Loading control state

Usage

This software is released into the public domain. You are free to use it in any way you like. You should save the Author text in the header files. If you modify it or extend it, please consider posting new code here for everyone to share. This software is provided "as is" with no expressed or implied warranty. I accept no liability for any damage or loss of business that this software may cause.

My special thanks to other authors.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Vitali Halershtein

Software Developer (Senior)

Belarus Belarus

Member

I am a professional Software Developer with more than 10 years' experience.
Certifications: MCSD, MCP, Brainbench, Masters Degree in Computer Science.
 
I am open for contacts and interesting ideas.
You can write me at:
vitali_eh@yahoo.com


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 4 PingroupMahdi Nejadsahebi19:09 27 Apr '12  
Generalexcellent and simple class with clistctrlex Pinmembermjchan13:57 16 Feb '05  
GeneralAdjustable Row Height PinmemberUmber19:47 17 Jun '04  
GeneralRe: Adjustable Row Height [modified] PinmemberVitali Halershtein22:40 17 Jun '04  
QuestionCan you do it in ATL with no MFC? Pinmember1of312:24 16 Jun '04  
AnswerRe: Can you do it in ATL with no MFC? [modified] PinmemberVitali Halershtein22:46 17 Jun '04  
GeneralCan't compile DemoProject_with_CListCtrlEx PinsussAnonymous23:03 22 Apr '04  
GeneralRe: Can't compile DemoProject_with_CListCtrlEx [modified] PinmemberVitali Halershtein23:59 26 Apr '04  
GeneralGreat Work Pinmemberhfrank13:27 28 Dec '03  
GeneralRe: Great Work [modified] PinmemberVitali Halershtein21:51 7 Jan '04  
GeneralRe: Great Work Pinmemberpietro777:30 10 Mar '04  
QuestionIs it possible??? Pinmembercwebiboy23:41 9 Dec '03  
AnswerRe: Is it possible??? PinmemberJohn M. Drescher0:17 10 Dec '03  
AnswerRe: Is it possible??? [modified] PinmemberVitali Halershtein0:45 10 Dec '03  
GeneralTimeout PinmemberDimitris Vassiliades0:29 11 Nov '03  
GeneralRe: Timeout PinmemberVitali Halershtein1:39 12 Nov '03  
GeneralParseSQL function Pinmemberrlieb12:15 15 Sep '03  
GeneralRe: ParseSQL function [modified] PinmemberVitali Halershtein20:32 15 Sep '03  
GeneralRe: ParseSQL function Pinmemberrlieb3:57 16 Sep '03  
GeneralRe: ParseSQL function PinmemberMattias G1:27 6 Oct '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 4 Nov 2003
Article Copyright 2003 by Vitali Halershtein
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid