?
Solved

Using ODBC with C++ and MFC

Posted on 2003-03-27
4
Medium Priority
?
229 Views
Last Modified: 2013-11-20
I am looking for an example of connecting to a Access database using ODBC to display existing records, and insert records. I know how to create the DSN what I do not understand is how to call the records and how/what to bind the records to so that they are visible in the dialog box. Also I used the wizard to create the ODBC stuff in the MFC application. For the main form CMyDBView I assume any code I would want to have exceute when the dialog box / form opens would go in the OnInitialUpdate() section. Does the code created by the wizard create any views that can be used?
0
Comment
Question by:martinjamesd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 8219895
Check out http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample/html/_core_Databases_Samples.asp ("Databases Samples") - it lists all MSDN DB samples, including ODBC.
0
 
LVL 2

Expert Comment

by:sreenu_v78
ID: 8223298
hai
Using CDatabase & CRecordset u can do
sample code like this

#include <afxdb.h>


CDatabase database;
database.OpenEx("DSN=dsnnamae");

//for insert data
CString query;
database.ExecuteSQL(query);


//for getting the records from data base
use recordset

CRecordset rs(&database);
rs.Open(CRecordset::dynaset,query);

go thru CRecordset Motheds in MSDN

best wishes
sreenu.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8722023
hi martinjamesd,
Do you still need help with this?
-- Dan
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

765 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