Link to home
Start Free TrialLog in
Avatar of docieb
docieb

asked on

How to ODBC

I have a project where I want to read an ODBC database and I would like to know a few things.  

1)How do I connect to a MDB database file with it, because the way I'm trying now isn't connecting.  This how I'm trying it as of right now:
      CDatabase* tmpDb = new CDatabase;
      try      // Attempt to open the new database before replacing our ptr
      {
            tmpDb->Open(lpszPathName);
      }
      catch (CException* e)
      {
            delete tmpDb;
            e->Delete();
            return;
      }
If I was using a SDI project, the wizard would do all the work for me but my project is a dialog based project so I need to figure out what all I need to do to get connected.

2) How can you access it through a list control.  I want to be able to Navigate through a table in the database with a list control if that is possible.  The data in the table will have a column called group and I would like for it to initially show all the groups and if you double click on group, it will then show all the entries that have the same group value.  When I am inside a group, I plan on having it where if you double click the first line in the list control, you go back up.  I know Microsoft has a sample project called Catalog2 which is suppose to demostrate how to use a list control but it isn't doing what I want and it lacks any description of how, why and what things are doing.   I guess I'm wanting more then examples, I'm wanting an understanding.
ASKER CERTIFIED SOLUTION
Avatar of mahesh1402
mahesh1402
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In above link refer CReadDBDlg::OnRead()  function... it reads mdb using CDatabase and CRecordset in Listcontrol..

MAHESH
for ODBC description with VC++ I will suggest you to refer this link..

http://www.softlookup.com/tutorial/vc++/vcu33fi.asp


MAHESH
Avatar of docieb
docieb

ASKER

Don't know how I didn't find the article at codeproject but thanks for the link.  Thats exactly what I wanted.  Thanks for pointing me to softloop.com, I wasn't familar with them until now.