• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

Using a ListView to display data from an ODBC connection

I am looking for an example of an ODBC database connection
that displays in a listview windows. The CRecordView class
that the wizard builds database program from sets up the
view windows as a formview. I am looking for a class that
is based on the CListView Class. I am not sure on how to do
this as I am new to C++ and MFC......................Dan
0
danmiller
Asked:
danmiller
1 Solution
 
jpk041897Commented:
You will need to use a CRecordSet class and fill in your CListView class (or derrived class) by hand.

I'm posting as a comment since I don't have sample source for your precise case. I do have code for a CListBox derrived class though so if you don't get anything better, let me know in a comment and I'll post that as an answer.
0
 
mikeblasCommented:
The DAOVIEW sample on the CD (and in help) shows how to hook a CListView to a CDaoRecordset.  In particular, look at the CDaoListView::ShowTableData() function in the file LISTVIEW.CPP.

.B ekiM
0
 
danmillerAuthor Commented:
 I took a look at the DAOVIEW sample and it looks interesting
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
mikeblasCommented:
Great.  Then, why did you reject my answer?

.B ekiM


0
 
danmillerAuthor Commented:
I did not mean to reject Mike's original answer , but is was not
the answer I was looking for. I am looking for more specific
details as to how to connect ClistView to a CRecordSet.
0
 
perrizoCommented:
In the last screen of the  App Wizard while creating your project the Wizard asks you if it should create the following classes for you

CApp
CMainFrame
CChildFrame
CDoc
CView

if you click on view you can change the type of view in the combo box below from a record view to a list view.  After you do this you'll have to use Class wizard to add a record set and add some code to the created view class.  Without listing the details of that code, you have to declare a member of your new record set class in your view, look at a recordview to see how they do this and for any other changes you may need to make.  If you want something more specific I can add that then but, I think if you try you'll be able to get it going.
0
 
mikeblasCommented:
What more specific details could you want than the code in a known-good sample that you already have?  If you want such infentessimal detail, perhaps you should so indicate in your question:  "I know I only asked for a sample, but I really want you to babysit me as I work on the implementation."

Then, we'll know what the _real_ deal is.

.B ekiM


0
 
danmillerAuthor Commented:
Mike I guess you are an expert with and attitude ? , I appologize
for not knowing how to program in MFC , I am just new to it. I
did specifically ask an ODBC question and you gave me a DAO ,
answer..........................................   Dan
0
 
danmillerAuthor Commented:
MIke , I was just talking to someone at my work and he convinced that you do not work for Microsoft , nor does he
believe that your wrote your own book any comments ?
0
 
mikeblasCommented:
The technique is exactly the same via DAO or ODBC.

Your colleague is welcome to send an email with his questions directly.

.B ekiM
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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