Solved

Opening ODBC connection

Posted on 2000-03-22
3
234 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 150 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
not able to insert into temp table 68 169
canBalance challenge 34 96
My project did see openJDK that I installed. What could be the problem 7 150
Change to event 1 117
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…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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…

790 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