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

VC++ & CDaoDatabase classes

I am trying to connect to Oracle database through
VC++,though there are special ODBC classes provided
by MFC,because of certain needs,I have to use
CDaoDatabase classes.But it is not getting connected
through ODBC.I think I am wrong somewhere because i
have never used ODBC.As there is Open method provided by
CDaoDatabase.If anybody can tell me how to connect to
Oracle database,to access all the tabledefs,and relationships
I will be thankful to you.It will be just small code.
And I think we can use ODBC API's also.But I don't know
how.VB programmers are used to connect to Oracle database.
But instead of connecting directly through ODBC,if you
know how to connect through JET engine.
Eagerly waiting for your reply.

1 Solution
I believe you have to use ODBC for Oracle. But below I show a code snippet opening a FoxPro database directly using DAO classes. Also in your online documentation search for accessing extrenal databases.

CDaoDatabase      *db_object;

// create and open  database object

 db_object= new CDaoDatabase (NULL);

if (db_object NOTEQUAL NULL)
      db_object->Open ("",FALSE,FALSE,_T("FoxPro                           2.5;DATABASE=D:\\DB"));
       CATCH (CDaoException,db_err)
       err_string.LoadString (IDS_OPEN_DBERR);
                  err_string +=          db_err->m_pErrorInfo->m_strDescription;
      AfxMessageBox (err_string,NULL,MB_OK);
       return FALSE;

you can then create a recorset object and open a specific table.

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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