Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Opening ODBC connection

Posted on 2000-03-22
3
Medium Priority
?
239 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
ID: 2648572
Have you set up the ODBC driver to look at your database file???
0
 
LVL 1

Accepted Solution

by:
carldean earned 600 total points
ID: 2649186
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
ID: 2660046
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
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.
Suggested Courses

971 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