-
August 31st, 2011, 02:45 AM
#1
Basic VC++ Question
Hey all,
I'm brand new to this forum and brand new to VC++, so go easy on me!
Here's what I'm trying to do:
I want to make an incredibly simply .exe program that will read data from a MS Access database which I've linked to an Excel document. I have 3 dropdown menu's and then a bunch of data-output text fields.
Basically, my question is this: For the 3 dropdown menus, each menu goes from a broad specific category to more and more specific items. So, once you make a selection in the first one, I need to have specific options for the second dropdown menus generated. Furthermore, once a selection is made in the 2nd dropdown menu, there will have to be options generated in the 3rd dropdown menu pulled from the database.
Once the final selection is made in the 3rd dropdown menu, I'd want to to read the database for that specific item and regurgitate all the values into text fields I've created which I can link to the database.
Here's what I've got so far: The first dropdown menu is simple, and I've added the options for that. I've made all the text fields where the data from the database will be regurgitated and can even link it, but can't figure out how to do it to a specific cell, and certainly haven't figured out how to get it to link the info automatically upon selection in the 3rd dropdown menu.
Anyways, as I said, go easy on me, and any help you can provide would be awesome.
Thanks,
Riznarf
-
August 31st, 2011, 05:09 AM
#2
Re: Basic VC++ Question
I believe, menus is not a right choice for the task of the sort. What looks more natural to me is either wizard-like dialog or two pane explorer like window with a categories tree pane on the left.
Of course dropdown menus could be built dynamically, but dynamic not of the sort you described. And definitely, fighting with old style Windows elements/controls native behavior never was "incredibly simple"
Best regards,
Igor
-
August 31st, 2011, 05:57 AM
#3
Re: Basic VC++ Question
Originally Posted by Igor Vartanov
I believe, menus is not a right choice for the task of the sort. What looks more natural to me is either wizard-like dialog or two pane explorer like window with a categories tree pane on the left.
Of course dropdown menus could be built dynamically, but dynamic not of the sort you described. And definitely, fighting with old style Windows elements/controls native behavior never was "incredibly simple"
Thanks for the prompt response. Yes, you're right. I have now made a tree pane on the left side of the window, however when I select the final item in the tree, how do I link it to the database to spit out all the data that I need?
-
August 31st, 2011, 06:25 AM
#4
Re: Basic VC++ Question
You could use MFC ODBC classes CDatabase and CRecordset.
Or ADO
Or OLEDB
Or just the old (and deprecated DAO)
Victor Nijegorodov
-
August 31st, 2011, 07:25 AM
#5
Re: Basic VC++ Question
Originally Posted by VictorN
You could use MFC ODBC classes CDatabase and CRecordset.
Or ADO
Or OLEDB
Or just the old (and deprecated DAO)
Hahah wow! I'm sure thats good advice, but as I said, brand new VC++ user here, gotta take it easy on me! Whats all that mean?
-
August 31st, 2011, 07:31 AM
#6
Re: Basic VC++ Question
Victor Nijegorodov
-
August 31st, 2011, 07:33 AM
#7
Re: Basic VC++ Question
Originally Posted by Riznarf
Hahah wow! I'm sure thats good advice, but as I said, brand new VC++ user here, gotta take it easy on me! Whats all that mean?
I would just start with the CRecordset class.
-
August 31st, 2011, 03:41 PM
#8
Re: Basic VC++ Question
I would start with the ATL OLEDB consumer classes.
See my reply and sample code of an app reading an Access db using ATL.
http://www.codeguru.com/forum/showthread.php?t=337819
P.S. Before you build the app, change the hardcoded path to the mdb database in the employees.h file. For some dumb reason I hardcoded it in the sample code.
Using the ATL OLEDB classes, here's how easy it is to read from a db table.
Code:
CEmployees employees;
if(SUCCEEDED( hr = employees.OpenAll() ))
{
while( S_OK == employees.MoveNext() )
{
lvitem.iItem = uItem;
lvitem.iSubItem = 0;
lvitem.pszText = employees.m_FirstName;
lvitem.cchTextMax = MAX_LVITEMLEN;
// Insert the item
m_ctlAccessDataList.InsertItem(&lvitem);
// Set the text for each column (all virtual callbacks)
m_ctlAccessDataList.SetItemText(uItem, 1, employees.m_LastName);
m_ctlAccessDataList.SetItemText(uItem, 2, employees.m_HomePhone);
uItem++;
}
}
else
{
// report error
}
Last edited by Arjay; August 31st, 2011 at 03:45 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|