ODBC Conversion

I want to convert an existing project to support ODBC how do I do it ?
Who is Participating?
PriyeshConnect With a Mentor Commented:
Please add #include <afxdb.h> in stdafx.h and
try using CDatabase and CRecordset classes.
For eg: see this.
            CDatabase db;
            db.OpenEx(_T( "DSN=XXX"),
                               CDatabase::openReadOnly |
                               CDatabase::noOdbcDialog ) ;
            CRecordset rs(&db);
                         _T("SELECT trade FROM SUPERNDC"));
            CString csWord ;
            char chSx[5] ;
            while( !rs.IsEOF() )
                  rs.GetFieldValue("trade", csWord);
                  if(Soundex((LPSTR)(LPCTSTR)csWord, chSx))
                        m_oList.AddItem((LPSTR)(LPCTSTR)csWord, chSx) ;
            catch(CDBException* pExp)
                  pExp->ReportError() ;

The above code can be used in a function to get instant access to a table and get data.. i used it to load data from a dictionary table to my data structure.. This should help u.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.