Solved

Opening ODBC connection

Posted on 2000-03-22
3
237 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
[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
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

 Watch the Recording: Learning MySQL 5.7

MySQL 5.7 has a lot of new features. If you've dabbled with an older version of MySQL, it is definitely worth learning.

Question has a verified solution.

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

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: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

615 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