Solved

ODBC Conversion

Posted on 1998-08-11
1
205 Views
Last Modified: 2013-11-20
I want to convert an existing project to support ODBC how do I do it ?
0
Comment
Question by:guranimo
1 Comment
 
LVL 9

Accepted Solution

by:
Priyesh earned 20 total points
ID: 1320561
Please add #include <afxdb.h> in stdafx.h and
try using CDatabase and CRecordset classes.
For eg: see this.
               try
            {
            CDatabase db;
            db.OpenEx(_T( "DSN=XXX"),
                               CDatabase::openReadOnly |
                               CDatabase::noOdbcDialog ) ;
            CRecordset rs(&db);
            rs.Open(CRecordset::forwardOnly,
                         _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) ;
                  rs.MoveNext();
            }
            rs.Close();
            db.Close();
            }
            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.
       Regards...
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
deburging in oracle form 12 99
countEvens challenge 2 100
sum67 challenge 35 97
either24  challenge 19 97
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question