Solved

ODBC Conversion

Posted on 1998-08-11
1
186 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 82
iSeries FTP Exit Program 8 113
List out all word 7 219
how to split multiple lines delimiter : 8 53
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now