Solved

Opening ODBC connection

Posted on 2000-03-22
3
230 Views
Last Modified: 2013-11-20
Hi... i am trying to create a connection to my odbc database object (access
97 object) and even though i specify a .mdb and table name in the wizard i
still get a prompt for an mdb file on initialization.

how do i stop this?

also, can anybody point me towards a basic framework example of this being implemented? all the examples i see are of specific problems being solved, and dont show the basic connection stuff.

finally, is a nice FAQ for beginners in vc++ database programming ?

thanx in advance
-Paul




0
Comment
Question by:Sesh
3 Comments
 

Expert Comment

by:wardkd
Comment Utility
Have you set up the ODBC driver to look at your database file???
0
 
LVL 1

Accepted Solution

by:
carldean earned 150 total points
Comment Utility
If you've done everything by the wizard approach then you've probably got...

1. An ODBC datasource pointed at your .MDB file.
2. A class-wizard generated CRecordset class that maps on to a table or query in your .MDB file.
3. A problem that when you run it it autmatically asks you what datasource to connect to.

If this is the case and you don't want this to happen then ...

A. The reason this happens is because the CDatabase* parameter on the CRecordset constructor is defaulted to NULL.  In such cases when you call CRecordset::Open it creates a temporary CDatabase object and pops up the ODBC DSN Select dialog so that you may choose a datasource.
B. To avoid this, create, programattically, your own CDatabase object and pass a pointer to it in your CRecordset constructor.

i.e. ...

CDatabase myDb();
myDb.open("MyDataSource", FALSE, FALSE, "ODBC;UID=FRED;PWD=DOG");

CMyRecordset myRecs(&myDb);
myRecs.Open();

0
 
LVL 3

Expert Comment

by:V_Bapat
Comment Utility
Since you have access database, I would suggest you use DAO classes provided by MFC.
Take a look at DaoTable and DaoView samples from MSDN.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to create frequencies of a variable from SAS dataset? 10 115
Folder Comparison 12 52
Host to IP 7 73
unix example issues 18 44
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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

743 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

9 Experts available now in Live!

Get 1:1 Help Now